home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 November / SGI Freeware 1999 November - Disc 1.iso / dist / fw_expect.idb / usr / freeware / catman / u_man / cat1 / expect.Z / expect
Text File  |  1999-01-26  |  115KB  |  2,509 lines

  1.  
  2.  
  3.  
  4.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       expect - programmed dialogue with interactive    programs,
  10.       Version 5
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.       eeeexxxxppppeeeecccctttt [ ----ddddDDDDiiiinnnnNNNN ] [ ----cccc _c_m_d_s ]    [ ----[ffff|bbbb] ] _c_m_d_f_i_l_e ] [ _a_r_g_s ]
  14.  
  15.      IIIINNNNTTTTRRRROOOODDDDUUUUCCCCTTTTIIIIOOOONNNN
  16.       EEEExxxxppppeeeecccctttt is a program that "talks" to other interactive
  17.       programs according to    a script.  Following the script,
  18.       EEEExxxxppppeeeecccctttt knows what can    be expected from a program and what
  19.       the correct response should be.  An interpreted language
  20.       provides branching and high-level control structures to
  21.       direct the dialogue.    In addition, the user can take control
  22.       and interact directly    when desired, afterward    returning
  23.       control to the script.
  24.  
  25.       EEEExxxxppppeeeeccccttttkkkk is a mixture of EEEExxxxppppeeeecccctttt and TTTTkkkk.  It behaves just like
  26.       EEEExxxxppppeeeecccctttt and TTTTkkkk's wwwwiiiisssshhhh.     EEEExxxxppppeeeecccctttt    can also be used directly in C
  27.       or C++ (that is, without Tcl).  See libexpect(3).
  28.  
  29.       The name "Expect" comes from the idea    of _s_e_n_d/_e_x_p_e_c_t
  30.       sequences popularized    by uucp, kermit    and other modem
  31.       control programs.  However unlike uucp, EEEExxxxppppeeeecccctttt is
  32.       generalized so that it can be    run as a user-level command
  33.       with any program and task in mind.  EEEExxxxppppeeeecccctttt can actually talk
  34.       to several programs at the same time.
  35.  
  36.       For example, here are    some things EEEExxxxppppeeeecccctttt can do:
  37.  
  38.            +o   Cause your computer to dial you back, so that you
  39.            can login without paying for    the call.
  40.  
  41.            +o   Start a game    (e.g., rogue) and if the optimal
  42.            configuration doesn't appear, restart it (again and
  43.            again) until    it does, then hand over    control    to
  44.            you.
  45.  
  46.            +o   Run fsck, and in response to    its questions, answer
  47.            "yes", "no" or give control back to you, based on
  48.            predetermined criteria.
  49.  
  50.            +o   Connect to another network or BBS (e.g., MCI    Mail,
  51.            CompuServe) and automatically retrieve your mail so
  52.            that    it appears as if it was    originally sent    to
  53.            your    local system.
  54.  
  55.            +o   Carry environment variables,    current    directory, or
  56.            any kind of information across rlogin, telnet, tip,
  57.            su, chgrp, etc.
  58.  
  59.       There    are a variety of reasons why the shell cannot perform
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 12/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  71.  
  72.  
  73.  
  74.       these    tasks.    (Try, you'll see.)  All    are possible with
  75.       EEEExxxxppppeeeecccctttt.
  76.  
  77.       In general, EEEExxxxppppeeeecccctttt is    useful for running any program which
  78.       requires interaction between the program and the user.  All
  79.       that is necessary is that the    interaction can    be
  80.       characterized    programmatically.  EEEExxxxppppeeeecccctttt can also give    the
  81.       user back control (without halting the program being
  82.       controlled) if desired.  Similarly, the user can return
  83.       control to the script    at any time.
  84.  
  85.      UUUUSSSSAAAAGGGGEEEE
  86.       EEEExxxxppppeeeecccctttt reads _c_m_d_f_i_l_e for a list of commands to execute.
  87.       EEEExxxxppppeeeecccctttt may also be invoked implicitly    on systems which
  88.       support the #! notation by marking the script    executable,
  89.       and making the first line in your script:
  90.  
  91.           #!/usr/local/bin/expect -f
  92.  
  93.       Of course, the path must accurately describe where EEEExxxxppppeeeecccctttt
  94.       lives.  /usr/local/bin is just an example.
  95.  
  96.       The ----cccc flag prefaces a command to be executed    before any in
  97.       the script.  The command should be quoted to prevent being
  98.       broken up by the shell.  This    option may be used multiple
  99.       times.  Multiple commands may    be executed with a single ----cccc
  100.       by separating    them with semicolons.  Commands    are executed
  101.       in the order they appear. (When using    Expectk, this option
  102.       is specified as ----ccccoooommmmmmmmaaaannnndddd.)
  103.  
  104.       The ----dddd flag enables some diagnostic output, which primarily
  105.       reports internal activity of commands    such as    eeeexxxxppppeeeecccctttt and
  106.       iiiinnnntttteeeerrrraaaacccctttt.  This flag has the same effect as "exp_internal 1"
  107.       at the beginning of an Expect    script,    plus the version of
  108.       EEEExxxxppppeeeecccctttt is printed.  (The ssssttttrrrraaaacccceeee command is useful for
  109.       tracing statements, and the ttttrrrraaaacccceeee command is useful for
  110.       tracing variable assignments.)  (When    using Expectk, this
  111.       option is specified as ----ddddiiiiaaaagggg.)
  112.  
  113.       The ----DDDD flag enables an interactive debugger.    An integer
  114.       value    should follow.    The debugger will take control before
  115.       the next Tcl procedure if the    value is non-zero or if    a ^C
  116.       is pressed (or a breakpoint is hit, or other appropriate
  117.       debugger command appears in the script).  See    the README
  118.       file or SEE ALSO (below) for more information    on the
  119.       debugger.  (When using Expectk, this option is specified as
  120.       ----DDDDeeeebbbbuuuugggg.)
  121.  
  122.       The ----ffff flag prefaces a file from which to read commands
  123.       from.     The flag itself is optional as    it is only useful when
  124.       using    the #! notation    (see above), so    that other arguments
  125.       may be supplied on the command line.    (When using Expectk,
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 12/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  137.  
  138.  
  139.  
  140.       this option is specified as ----ffffiiiilllleeee.)
  141.  
  142.       By default, the command file is read into memory and
  143.       executed in its entirety.  It    is occasionally    desirable to
  144.       read files one line at a time.  For example, stdin is    read
  145.       this way.  In    order to force arbitrary files to be handled
  146.       this way, use    the ----bbbb flag.  (When using Expectk, this    option
  147.       is specified as ----bbbbuuuuffffffffeeeerrrr.)
  148.  
  149.       If the string    "-" is supplied    as a filename, standard    input
  150.       is read instead.  (Use "./-" to read from a file actually
  151.       named    "-".)
  152.  
  153.       The ----iiii flag causes EEEExxxxppppeeeecccctttt to interactively prompt for
  154.       commands instead of reading them from    a file.     Prompting is
  155.       terminated via the eeeexxxxiiiitttt command or upon EOF.    See
  156.       iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr (below) for more information.  ----iiii    is assumed if
  157.       neither a command file nor ----cccc    is used.  (When    using Expectk,
  158.       this option is specified as ----iiiinnnntttteeeerrrraaaaccccttttiiiivvvveeee.)
  159.  
  160.       -------- may be used to delimit the    end of the options.  This is
  161.       useful if you    want to    pass an    option-like argument to    your
  162.       script without it being interpreted by EEEExxxxppppeeeecccctttt.  This can
  163.       usefully be placed in    the #! line to prevent any flag-like
  164.       interpretation by Expect.  For example, the following    will
  165.       leave    the original arguments (including the script name) in
  166.       the variable _a_r_g_v.
  167.  
  168.           #!/usr/local/bin/expect --
  169.  
  170.       Note that the    usual getopt(3)    and execve(2) conventions must
  171.       be observed when adding arguments to the #! line.
  172.  
  173.       The file $exp_library/expect.rc is sourced automatically if
  174.       present, unless the ----NNNN flag is used. (When using Expectk,
  175.       this option is specified as ----NNNNOOOORRRRCCCC.)  Immediately after this,
  176.       the file ~/.expect.rc    is sourced automatically, unless the
  177.       ----nnnn flag is used.  If the environment variable    DOTDIR is
  178.       defined, it is treated as a directory    and .expect.rc is read
  179.       from there.  (When using Expectk, this option    is specified
  180.       as ----nnnnoooorrrrcccc.)  This sourcing occurs only    after executing    any ----cccc
  181.       flags.
  182.  
  183.       ----vvvv causes Expect to print its    version    number and exit.  (The
  184.       corresponding    flag in    Expectk, which uses long flag names,
  185.       is -version.)
  186.  
  187.       Optional _a_r_g_s    are constructed    into a list and    stored in the
  188.       variable named _a_r_g_v.    _a_r_g_c is    initialized to the length of
  189.       argv.
  190.  
  191.       _a_r_g_v_0    is defined to be the name of the script    (or binary if
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 12/23/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  203.  
  204.  
  205.  
  206.       no script is used).  For example, the    following prints out
  207.       the name of the script and the first three arguments:
  208.  
  209.           send_user    "$argv0    [lrange    $argv 0    2]\n"
  210.  
  211.  
  212.      CCCCOOOOMMMMMMMMAAAANNNNDDDDSSSS
  213.       EEEExxxxppppeeeecccctttt uses _T_c_l (Tool    Command    Language).  Tcl    provides
  214.       control flow (e.g., if, for, break), expression evaluation
  215.       and several other features such as recursion,    procedure
  216.       definition, etc.  Commands used here but not defined (e.g.,
  217.       sssseeeetttt, iiiiffff, eeeexxxxeeeecccc) are Tcl commands (see tcl(3)).     EEEExxxxppppeeeecccctttt
  218.       supports additional commands,    described below.  Unless
  219.       otherwise specified, commands    return the empty string.
  220.  
  221.       Commands are listed alphabetically so    that they can be
  222.       quickly located.  However, new users may find    it easier to
  223.       start    by reading the descriptions of ssssppppaaaawwwwnnnn, sssseeeennnndddd, eeeexxxxppppeeeecccctttt,
  224.       and iiiinnnntttteeeerrrraaaacccctttt,    in that    order.
  225.  
  226.       Note that the    best introduction to the language (both    Expect
  227.       and Tcl) is provided in the book "Exploring Expect" (see SEE
  228.       ALSO below).    Examples are included in this man page but
  229.       they are very    limited    since this man page is meant primarily
  230.       as reference material.
  231.  
  232.       Note that in the text    of this    man page, "Expect" with    an
  233.       uppercase "E"    refers to the EEEExxxxppppeeeecccctttt program while "expect"
  234.       with a lower-case "e"    refers to the eeeexxxxppppeeeecccctttt command within
  235.       the EEEExxxxppppeeeecccctttt program.)
  236.  
  237.       cccclllloooosssseeee    [-_s_l_a_v_e] [-_o_n_e_x_e_c _0|_1] [-_i _s_p_a_w_n__i_d]
  238.         closes the connection to the current process.  Most
  239.         interactive programs will detect EOF on    their stdin
  240.         and exit; thus cccclllloooosssseeee usually suffices to kill the
  241.         process    as well.  The ----iiii flag declares the process to
  242.         close corresponding to the named spawn_id.
  243.  
  244.         Both eeeexxxxppppeeeecccctttt and    iiiinnnntttteeeerrrraaaacccctttt will detect when the current
  245.         process    exits and implicitly do    a cccclllloooosssseeee.  But if you
  246.         kill the process by, say, "exec    kill $pid", you    will
  247.         need to    explicitly call    cccclllloooosssseeee.
  248.  
  249.         The ----oooonnnneeeexxxxeeeecccc flag determines whether the    spawn id will
  250.         be closed in any new spawned processes or if the
  251.         process    is overlayed.  To leave    a spawn    id open, use
  252.         the value 0.  A    non-zero integer value will force the
  253.         spawn closed (the default) in any new processes.
  254.  
  255.         The ----ssssllllaaaavvvveeee flag    closes the slave associated with the
  256.         spawn id.  (See    "spawn -pty".)    When the connection is
  257.         closed,    the slave is automatically closed as well if
  258.  
  259.  
  260.  
  261.      Page 4                        (printed 12/23/98)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  269.  
  270.  
  271.  
  272.         still open.
  273.  
  274.         No matter whether the connection is closed implicitly
  275.         or explicitly, you should call wwwwaaaaiiiitttt to clear up    the
  276.         corresponding kernel process slot.  cccclllloooosssseeee does not
  277.         call wwwwaaaaiiiitttt since    there is no guarantee that closing a
  278.         process    connection will    cause it to exit.  See wwwwaaaaiiiitttt
  279.         below for more info.
  280.  
  281.       ddddeeeebbbbuuuugggg    [[-_n_o_w]    _0|_1]
  282.         controls a Tcl debugger    allowing you to    step through
  283.         statements, set    breakpoints, etc.
  284.  
  285.         With no    arguments, a 1 is returned if the debugger is
  286.         not running, otherwise a 0 is returned.
  287.  
  288.         With a 1 argument, the debugger    is started.  With a 0
  289.         argument, the debugger is stopped.  If a 1 argument is
  290.         preceded by the    ----nnnnoooowwww flag, the debugger    is started
  291.         immediately (i.e., in the middle of the    ddddeeeebbbbuuuugggg command
  292.         itself).  Otherwise, the debugger is started with the
  293.         next Tcl statement.
  294.  
  295.         The ddddeeeebbbbuuuugggg command does not change any traps.  Compare
  296.         this to    starting Expect    with the ----DDDD flag (see above).
  297.  
  298.         See the    README file or SEE ALSO    (below)    for more
  299.         information on the debugger.
  300.  
  301.       ddddiiiissssccccoooonnnnnnnneeeecccctttt
  302.         disconnects a forked process from the terminal.     It
  303.         continues running in the background.  The process is
  304.         given its own process group (if    possible).  Standard
  305.         I/O is redirected to /dev/null.
  306.  
  307.         The following fragment uses ddddiiiissssccccoooonnnnnnnneeeecccctttt to continue
  308.         running    the script in the background.
  309.  
  310.             if [fork]!=0 exit
  311.             disconnect
  312.             . .    .
  313.  
  314.         The following script reads a password, and then    runs a
  315.         program    every hour that    demands    a password each    time
  316.         it is run.  The    script supplies    the password so    that
  317.         you only have to type it once.    (See the ssssttttttttyyyy command
  318.         which demonstrates how to turn off password echoing.)
  319.  
  320.             send_user "password?\ "
  321.             expect_user    -re "(.*)\n"
  322.             for    {} 1 {}    {
  323.             if [fork]!=0 {sleep 3600;continue}
  324.  
  325.  
  326.  
  327.      Page 5                        (printed 12/23/98)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  335.  
  336.  
  337.  
  338.             disconnect
  339.             spawn priv_prog
  340.             expect Password:
  341.             send "$expect_out(1,string)\r"
  342.             . . .
  343.             exit
  344.             }
  345.  
  346.         An advantage to    using ddddiiiissssccccoooonnnnnnnneeeecccctttt over the shell
  347.         asynchronous process feature (&) is that EEEExxxxppppeeeecccctttt    can
  348.         save the terminal parameters prior to disconnection,
  349.         and then later apply them to new ptys.    With &,    EEEExxxxppppeeeecccctttt
  350.         does not have a    chance to read the terminal's
  351.         parameters since the terminal is already disconnected
  352.         by the time EEEExxxxppppeeeecccctttt receives control.
  353.  
  354.       eeeexxxxiiiitttt [-_o_p_t_s] [_s_t_a_t_u_s]
  355.         causes EEEExxxxppppeeeecccctttt to exit or otherwise prepare to do so.
  356.  
  357.         The ----oooonnnneeeexxxxiiiitttt flag causes    the next argument to be    used
  358.         as an exit handler.  Without an    argument, the current
  359.         exit handler is    returned.
  360.  
  361.         The ----nnnnooooeeeexxxxiiiitttt flag causes    EEEExxxxppppeeeecccctttt to prepare to exit but
  362.         stop short of actually returning control to the
  363.         operating system.  The user-defined exit handler is
  364.         run as well as Expect's    own internal handlers.    No
  365.         further    Expect commands    should be executed.  This is
  366.         useful if you are running Expect with other Tcl
  367.         extensions.  The current interpreter (and main window
  368.         if in the Tk environment) remain so that other Tcl
  369.         extensions can clean up.  If Expect's eeeexxxxiiiitttt is called
  370.         again (however this might occur), the handlers are not
  371.         rerun.
  372.  
  373.         Upon exiting, all connections to spawned processes are
  374.         closed.     Closure will be detected as an    EOF by spawned
  375.         processes.  eeeexxxxiiiitttt takes no other    actions    beyond what
  376.         the normal _exit(2) procedure does.  Thus, spawned
  377.         processes that do not check for    EOF may    continue to
  378.         run.  (A variety of conditions are important to
  379.         determining, for example, what signals a spawned
  380.         process    will be    sent, but these    are system-dependent,
  381.         typically documented under exit(3).)  Spawned
  382.         processes that continue    to run will be inherited by
  383.         init.
  384.  
  385.         _s_t_a_t_u_s (or 0 if    not specified) is returned as the exit
  386.         status of EEEExxxxppppeeeecccctttt.  eeeexxxxiiiitttt    is implicitly executed if the
  387.         end of the script is reached.
  388.  
  389.       eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee
  390.  
  391.  
  392.  
  393.      Page 6                        (printed 12/23/98)
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  401.  
  402.  
  403.  
  404.         The command eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee allows    eeeexxxxppppeeeecccctttt itself to
  405.         continue executing rather than returning as it
  406.         normally would.     (See eeeexxxxppppeeeecccctttt for more information.)
  407.  
  408.       eeeexxxxpppp____iiiinnnntttteeeerrrrnnnnaaaallll [-_f _f_i_l_e] _v_a_l_u_e
  409.         causes further commands    to send    diagnostic information
  410.         internal to EEEExxxxppppeeeecccctttt to stderr if    _v_a_l_u_e is non-zero.
  411.         This output is disabled    if _v_a_l_u_e is 0.    The diagnostic
  412.         information includes every character received, and
  413.         every attempt made to match the    current    output against
  414.         the patterns.
  415.  
  416.         If the optional    _f_i_l_e is    supplied, all normal and
  417.         debugging output is written to that file (regardless
  418.         of the value of    _v_a_l_u_e).     Any previous diagnostic
  419.         output file is closed.
  420.  
  421.         The ----iiiinnnnffffoooo flag causes exp_internal to return a
  422.         description of the most    recent non-info    arguments
  423.         given.
  424.  
  425.       eeeexxxxpppp____ooooppppeeeennnn [_a_r_g_s] [-_i _s_p_a_w_n__i_d]
  426.         returns    a Tcl file identifier that corresponds to the
  427.         original spawn id.  The    file identifier    can then be
  428.         used as    if it were opened by Tcl's ooooppppeeeennnn    command.  (The
  429.         spawn id should    no longer be used.  A wwwwaaaaiiiitttt should not
  430.         be executed.
  431.  
  432.         The ----lllleeeeaaaavvvveeeeooooppppeeeennnn flag leaves the spawn id    open for
  433.         access through Expect commands.     A wwwwaaaaiiiitttt    must be
  434.         executed on the    spawn id.
  435.  
  436.       eeeexxxxpppp____ppppiiiidddd [-_i _s_p_a_w_n__i_d]
  437.         returns    the process id corresponding to    the currently
  438.         spawned    process.  If the ----iiii flag is used, the pid
  439.         returned corresponds to    that of    the given spawn    id.
  440.  
  441.       eeeexxxxpppp____sssseeeennnndddd
  442.         is an alias for    sssseeeennnndddd.
  443.  
  444.       eeeexxxxpppp____sssseeeennnndddd____eeeerrrrrrrroooorrrr
  445.         is an alias for    sssseeeennnndddd____eeeerrrrrrrroooorrrr.
  446.  
  447.       eeeexxxxpppp____sssseeeennnndddd____lllloooogggg
  448.         is an alias for    sssseeeennnndddd____lllloooogggg.
  449.  
  450.       eeeexxxxpppp____sssseeeennnndddd____ttttttttyyyy
  451.         is an alias for    sssseeeennnndddd____ttttttttyyyy.
  452.  
  453.       eeeexxxxpppp____sssseeeennnndddd____uuuusssseeeerrrr
  454.         is an alias for    sssseeeennnndddd____uuuusssseeeerrrr.
  455.  
  456.  
  457.  
  458.  
  459.      Page 7                        (printed 12/23/98)
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  467.  
  468.  
  469.  
  470.       eeeexxxxpppp____vvvveeeerrrrssssiiiioooonnnn [[-_e_x_i_t] _v_e_r_s_i_o_n]
  471.         is useful for assuring that the    script is compatible
  472.         with the current version of Expect.
  473.  
  474.         With no    arguments, the current version of EEEExxxxppppeeeecccctttt is
  475.         returned.  This    version    may then be encoded in your
  476.         script.     If you    actually know that you are not using
  477.         features of recent versions, you can specify an
  478.         earlier    version.
  479.  
  480.         Versions consist of three numbers separated by dots.
  481.         First is the major number.  Scripts written for
  482.         versions of EEEExxxxppppeeeecccctttt with    a different major number will
  483.         almost certainly not work.  eeeexxxxpppp____vvvveeeerrrrssssiiiioooonnnn    returns    an
  484.         error if the major numbers do not match.
  485.  
  486.         Second is the minor number.  Scripts written for a
  487.         version    with a greater minor number than the current
  488.         version    may depend upon    some new feature and might not
  489.         run.  eeeexxxxpppp____vvvveeeerrrrssssiiiioooonnnn returns an error if the major
  490.         numbers    match, but the script minor number is greater
  491.         than that of the running EEEExxxxppppeeeecccctttt.
  492.  
  493.         Third is a number that plays no    part in    the version
  494.         comparison.  However, it is incremented    when the
  495.         EEEExxxxppppeeeecccctttt software    distribution is    changed    in any way,
  496.         such as    by additional documentation or optimization.
  497.         It is reset to 0 upon each new minor version.
  498.  
  499.         With the ----eeeexxxxiiiitttt flag, EEEExxxxppppeeeecccctttt prints an error and    exits
  500.         if the version is out of date.
  501.  
  502.       eeeexxxxppppeeeecccctttt [[-_o_p_t_s] _p_a_t_1 _b_o_d_y_1] ... [-_o_p_t_s] _p_a_t_n [_b_o_d_y_n]
  503.         waits until one    of the patterns    matches    the output of
  504.         a spawned process, a specified time period has passed,
  505.         or an end-of-file is seen.  If the final body is
  506.         empty, it may be omitted.
  507.  
  508.         Patterns from the most recent eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee command
  509.         are implicitly used before any other patterns.
  510.         Patterns from the most recent eeeexxxxppppeeeecccctttt____aaaafffftttteeeerrrr command are
  511.         implicitly used    after any other    patterns.
  512.  
  513.         If the arguments to the    entire eeeexxxxppppeeeecccctttt statement
  514.         require    more than one line, all    the arguments may be
  515.         "braced" into one so as    to avoid terminating each line
  516.         with a backslash.  In this one case, the usual Tcl
  517.         substitutions will occur despite the braces.
  518.  
  519.         If a pattern is    the keyword eeeeooooffff, the corresponding
  520.         body is    executed upon end-of-file.  If a pattern is
  521.         the keyword ttttiiiimmmmeeeeoooouuuutttt, the corresponding body is
  522.  
  523.  
  524.  
  525.      Page 8                        (printed 12/23/98)
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  533.  
  534.  
  535.  
  536.         executed upon timeout.    If no timeout keyword is used,
  537.         an implicit null action    is executed upon timeout.  The
  538.         default    timeout    period is 10 seconds but may be    set,
  539.         for example to 30, by the command "set timeout 30".
  540.         An infinite timeout may    be designated by the value -1.
  541.         If a pattern is    the keyword ddddeeeeffffaaaauuuulllltttt, the corresponding
  542.         body is    executed upon either timeout or    end-of-file.
  543.  
  544.         If a pattern matches, then the corresponding body is
  545.         executed.  eeeexxxxppppeeeecccctttt returns the result of    the body (or
  546.         the empty string if no pattern matched).  In the event
  547.         that multiple patterns match, the one appearing    first
  548.         is used    to select a body.
  549.  
  550.         Each time new output arrives, it is compared to    each
  551.         pattern    in the order they are listed.  Thus, you may
  552.         test for absence of a match by making the last pattern
  553.         something guaranteed to    appear,    such as    a prompt.  In
  554.         situations where there is no prompt, you must use
  555.         ttttiiiimmmmeeeeoooouuuutttt    (just like you would if    you were interacting
  556.         manually).
  557.  
  558.         Patterns are specified in three    ways.  By default,
  559.         patterns are specified as with Tcl's ssssttttrrrriiiinnnngggg mmmmaaaattttcccchhhh
  560.         command.  (Such    patterns are also similar to C-shell
  561.         regular    expressions usually referred to    as "glob"
  562.         patterns).  The    ----ggggllll flag may may be used to protect
  563.         patterns that might otherwise match eeeexxxxppppeeeecccctttt flags from
  564.         doing so.  Any pattern beginning with a    "-" should be
  565.         protected this way.  (All strings starting with    "-"
  566.         are reserved for future    options.)
  567.  
  568.  
  569.         For example, the following fragment looks for a
  570.         successful login.  (Note that aaaabbbboooorrrrtttt is presumed    to be
  571.         a procedure defined elsewhere in the script.)
  572.  
  573.             expect {
  574.             busy           {puts busy\n    ; exp_continue}
  575.             failed           abort
  576.             "invalid password" abort
  577.             timeout           abort
  578.             connected
  579.             }
  580.  
  581.         Quotes are necessary on    the fourth pattern since it
  582.         contains a space, which    would otherwise    separate the
  583.         pattern    from the action.  Patterns with    the same
  584.         action (such as    the 3rd    and 4th) require listing the
  585.         actions    again.    This can be avoid by using regexp-
  586.         style patterns (see below).  More information on
  587.         forming    glob-style patterns can    be found in the    Tcl
  588.  
  589.  
  590.  
  591.      Page 9                        (printed 12/23/98)
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  599.  
  600.  
  601.  
  602.         manual.
  603.  
  604.         Regexp-style patterns follow the syntax    defined    by
  605.         Tcl's rrrreeeeggggeeeexxxxpppp (short for    "regular expression") command.
  606.         regexp patterns    are introduced with the    flag ----rrrreeee.  The
  607.         previous example can be    rewritten using    a regexp as:
  608.  
  609.             expect {
  610.             busy       {puts busy\n    ; exp_continue}
  611.             -re "failed|invalid password" abort
  612.             timeout       abort
  613.             connected
  614.             }
  615.  
  616.         Both types of patterns are "unanchored".  This means
  617.         that patterns do not have to match the entire string,
  618.         but can    begin and end the match    anywhere in the    string
  619.         (as long as everything else matches).  Use ^ to    match
  620.         the beginning of a string, and $ to match the end.
  621.         Note that if you do not    wait for the end of a string,
  622.         your responses can easily end up in the    middle of the
  623.         string as they are echoed from the spawned process.
  624.         While still producing correct results, the output can
  625.         look unnatural.     Thus, use of $    is encouraged if you
  626.         can exactly describe the characters at the end of a
  627.         string.
  628.  
  629.         Note that in many editors, the ^ and $ match the
  630.         beginning and end of lines respectively. However,
  631.         because    expect is not line oriented, these characters
  632.         match the beginning and    end of the data    (as opposed to
  633.         lines) currently in the    expect matching    buffer.
  634.         (Also, see the note below on "system indigestion.")
  635.  
  636.         The ----eeeexxxx    flag causes the    pattern    to be matched as an
  637.         "exact"    string.     No interpretation of *, ^, etc    is
  638.         made (although the usual Tcl conventions must still be
  639.         observed).  Exact patterns are always unanchored.
  640.  
  641.  
  642.         The ----nnnnooooccccaaaasssseeee flag causes    uppercase characters of    the
  643.         output to compare as if    they were lowercase
  644.         characters.  The pattern is not    affected.
  645.  
  646.         While reading output, more than    2000 bytes can force
  647.         earlier    bytes to be "forgotten".  This may be changed
  648.         with the function mmmmaaaattttcccchhhh____mmmmaaaaxxxx.  (Note that excessively
  649.         large values can slow down the pattern matcher.)  If
  650.         _p_a_t_l_i_s_t    is ffffuuuullllllll____bbbbuuuuffffffffeeeerrrr,    the corresponding body is
  651.         executed if _m_a_t_c_h__m_a_x bytes have been received and no
  652.         other patterns have matched.  Whether or not the
  653.         ffffuuuullllllll____bbbbuuuuffffffffeeeerrrr keyword is used, the forgotten characters
  654.  
  655.  
  656.  
  657.      Page 10                        (printed 12/23/98)
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  665.  
  666.  
  667.  
  668.         are written to expect_out(buffer).
  669.  
  670.         If _p_a_t_l_i_s_t is the keyword nnnnuuuullllllll,    and nulls are allowed
  671.         (via the rrrreeeemmmmoooovvvveeee____nnnnuuuullllllllssss command),    the corresponding body
  672.         is executed if a single    ASCII 0    is matched.  It    is not
  673.         possible to match 0 bytes via glob or regexp patterns.
  674.  
  675.         Upon matching a    pattern    (or eof    or full_buffer), any
  676.         matching and previously    unmatched output is saved in
  677.         the variable _e_x_p_e_c_t__o_u_t(_b_u_f_f_e_r).  Up to    9 regexp
  678.         substring matches are saved in the variables
  679.         _e_x_p_e_c_t__o_u_t(_1,_s_t_r_i_n_g) through _e_x_p_e_c_t__o_u_t(_9,_s_t_r_i_n_g).  If
  680.         the ----iiiinnnnddddiiiicccceeeessss flag is used before a pattern, the
  681.         starting and ending indices (in    a form suitable    for
  682.         llllrrrraaaannnnggggeeee)    of the 10 strings are stored in    the variables
  683.         _e_x_p_e_c_t__o_u_t(_X,_s_t_a_r_t) and    _e_x_p_e_c_t__o_u_t(_X,_e_n_d) where    X is a
  684.         digit, corresponds to the substring position in    the
  685.         buffer.     0 refers to strings which matched the entire
  686.         pattern    and is generated for glob patterns as well as
  687.         regexp patterns.  For example, if a process has
  688.         produced output    of "abcdefgh\n", the result of:
  689.  
  690.             expect "cd"
  691.  
  692.         is as if the following statements had executed:
  693.  
  694.             set    expect_out(0,string) cd
  695.             set    expect_out(buffer) abcd
  696.  
  697.         and "efgh\n" is    left in    the output buffer.  If a
  698.         process    produced the output "abbbcabkkkka\n", the
  699.         result of:
  700.  
  701.             expect -indices -re    "b(b*).*(k+)"
  702.  
  703.         is as if the following statements had executed:
  704.  
  705.             set    expect_out(0,start) 1
  706.             set    expect_out(0,end) 10
  707.             set    expect_out(0,string) bbbcabkkkk
  708.             set    expect_out(1,start) 2
  709.             set    expect_out(1,end) 3
  710.             set    expect_out(1,string) bb
  711.             set    expect_out(2,start) 10
  712.             set    expect_out(2,end) 10
  713.             set    expect_out(2,string) k
  714.             set    expect_out(buffer) abbbcabkkkk
  715.  
  716.         and "a\n" is left in the output    buffer.     The pattern
  717.         "*" (and -re ".*") will    flush the output buffer
  718.         without    reading    any more output    from the process.
  719.  
  720.  
  721.  
  722.  
  723.      Page 11                        (printed 12/23/98)
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  731.  
  732.  
  733.  
  734.         Normally, the matched output is    discarded from
  735.         Expect's internal buffers.  This may be    prevented by
  736.         prefixing a pattern with the ----nnnnoooottttrrrraaaannnnssssffffeeeerrrr flag.    This
  737.         flag is    especially useful in experimenting (and    can be
  738.         abbreviated to "-n" for    convenience while
  739.         experimenting).
  740.  
  741.         The spawn id associated    with the matching output (or
  742.         eof or full_buffer) is stored in _e_x_p_e_c_t__o_u_t(_s_p_a_w_n__i_d).
  743.  
  744.         The ----ttttiiiimmmmeeeeoooouuuutttt flag causes the current expect command to
  745.         use the    following value    as a timeout instead of    using
  746.         the value of the timeout variable.
  747.  
  748.         By default, patterns are matched against output    from
  749.         the current process, however the ----iiii flag declares the
  750.         output from the    named spawn_id list be matched against
  751.         any following patterns (up to the next ----iiii).  The
  752.         spawn_id list should either be a whitespace separated
  753.         list of    spawn_ids or a variable    referring to such a
  754.         list of    spawn_ids.
  755.  
  756.         For example, the following example waits for
  757.         "connected" from the current process, or "busy",
  758.         "failed" or "invalid password" from the    spawn_id named
  759.         by $proc2.
  760.  
  761.             expect {
  762.             -i $proc2 busy {puts busy\n ; exp_continue}
  763.             -re "failed|invalid password" abort
  764.             timeout    abort
  765.             connected
  766.             }
  767.  
  768.         The value of the global    variable _a_n_y__s_p_a_w_n__i_d may be
  769.         used to    match patterns to any spawn_ids    that are named
  770.         with all other ----iiii flags    in the current eeeexxxxppppeeeecccctttt command.
  771.         The spawn_id from a ----iiii flag with no associated pattern
  772.         (i.e., followed    immediately by another ----iiii) is made
  773.         available to any other patterns    in the same eeeexxxxppppeeeecccctttt
  774.         command    associated with    _a_n_y__s_p_a_w_n__i_d.
  775.  
  776.         The ----iiii flag may    also name a global variable in which
  777.         case the variable is read for a    list of    spawn ids.
  778.         The variable is    reread whenever    it changes.  This
  779.         provides a way of changing the I/O source while    the
  780.         command    is in execution.  Spawn    ids provided this way
  781.         are called "indirect" spawn ids.
  782.  
  783.         Actions    such as    bbbbrrrreeeeaaaakkkk and ccccoooonnnnttttiiiinnnnuuuueeee cause control
  784.         structures (i.e., ffffoooorrrr, pppprrrroooocccc) to    behave in the usual
  785.         way.  The command eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee allows eeeexxxxppppeeeecccctttt itself to
  786.  
  787.  
  788.  
  789.      Page 12                        (printed 12/23/98)
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  797.  
  798.  
  799.  
  800.         continue executing rather than returning as it
  801.         normally would.
  802.  
  803.         This is    useful for avoiding explicit loops or repeated
  804.         expect statements.  The    following example is part of a
  805.         fragment to automate rlogin.  The eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee avoids
  806.         having to write    a second eeeexxxxppppeeeecccctttt    statement (to look for
  807.         the prompt again) if the rlogin    prompts    for a
  808.         password.
  809.  
  810.             expect {
  811.             Password: {
  812.                 stty -echo
  813.                 send_user "password    (for $user) on $host: "
  814.                 expect_user    -re "(.*)\n"
  815.                 send_user "\n"
  816.                 send "$expect_out(1,string)\r"
  817.                 stty echo
  818.                 exp_continue
  819.             } incorrect {
  820.                 send_user "invalid password    or account\n"
  821.                 exit
  822.             } timeout {
  823.                 send_user "connection to $host timed out\n"
  824.                 exit
  825.             } eof {
  826.                 send_user \
  827.                 "connection to host failed: $expect_out(buffer)"
  828.                 exit
  829.             } -re $prompt
  830.             }
  831.  
  832.         For example, the following fragment might help a user
  833.         guide an interaction that is already totally
  834.         automated.  In this case, the terminal is put into raw
  835.         mode.  If the user presses "+",    a variable is
  836.         incremented.  If "p" is    pressed, several returns are
  837.         sent to    the process, perhaps to    poke it    in some    way,
  838.         and "i"    lets the user interact with the    process,
  839.         effectively stealing away control from the script.  In
  840.         each case, the eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee allows the current eeeexxxxppppeeeecccctttt
  841.         to continue pattern matching after executing the
  842.         current    action.
  843.  
  844.             stty raw -echo
  845.             expect_after {
  846.             -i $user_spawn_id
  847.             "p" {send "\r\r\r"; exp_continue}
  848.             "+" {incr foo; exp_continue}
  849.             "i" {interact; exp_continue}
  850.             "quit" exit
  851.             }
  852.  
  853.  
  854.  
  855.      Page 13                        (printed 12/23/98)
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  863.  
  864.  
  865.  
  866.         By default, eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee resets    the timeout timer.
  867.         The timer is not restarted, if eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee is called
  868.         with the ----ccccoooonnnnttttiiiinnnnuuuueeee____ttttiiiimmmmeeeerrrr flag.
  869.  
  870.       eeeexxxxppppeeeecccctttt____aaaafffftttteeeerrrr [_e_x_p_e_c_t__a_r_g_s]
  871.         works identically to the eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee except that if
  872.         patterns from both eeeexxxxppppeeeecccctttt and eeeexxxxppppeeeecccctttt____aaaafffftttteeeerrrr can match,
  873.         the eeeexxxxppppeeeecccctttt pattern is used.  See the eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee
  874.         command    for more information.
  875.  
  876.       eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd [_e_x_p_e_c_t__a_r_g_s]
  877.         takes the same arguments as eeeexxxxppppeeeecccctttt, however it returns
  878.         immediately.  Patterns are tested whenever new input
  879.         arrives.  The pattern ttttiiiimmmmeeeeoooouuuutttt and ddddeeeeffffaaaauuuulllltttt are
  880.         meaningless to eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd and are silently
  881.         discarded.  Otherwise, the eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd command
  882.         uses eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee and eeeexxxxppppeeeecccctttt____aaaafffftttteeeerrrr patterns just like
  883.         eeeexxxxppppeeeecccctttt does.
  884.  
  885.         When eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd actions are being evaluated,
  886.         background processing for the same spawn id is
  887.         blocked.  Background processing    is unblocked when the
  888.         action completes.  While background processing is
  889.         blocked, it is possible    to do a    (foreground) eeeexxxxppppeeeecccctttt on
  890.         the same spawn id.
  891.  
  892.         It is not possible to execute an eeeexxxxppppeeeecccctttt    while an
  893.         eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd is unblocked.     eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd for
  894.         a particular spawn id is deleted by declaring a    new
  895.         expect_background with the same    spawn id.  Declaring
  896.         eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd with no pattern removes the given
  897.         spawn id from the ability to match patterns in the
  898.         background.
  899.  
  900.       eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee    [_e_x_p_e_c_t__a_r_g_s]
  901.         takes the same arguments as eeeexxxxppppeeeecccctttt, however it returns
  902.         immediately.  Pattern-action pairs from    the most
  903.         recent eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee with the same spawn id are
  904.         implicitly added to any    following eeeexxxxppppeeeecccctttt commands.  If
  905.         a pattern matches, it is treated as if it had been
  906.         specified in the eeeexxxxppppeeeecccctttt    command    itself,    and the
  907.         associated body    is executed in the context of the
  908.         eeeexxxxppppeeeecccctttt command.     If patterns from both eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee
  909.         and eeeexxxxppppeeeecccctttt can match, the eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee    pattern    is
  910.         used.
  911.  
  912.         If no pattern is specified, the    spawn id is not
  913.         checked    for any    patterns.
  914.  
  915.         Unless overridden by a ----iiii flag,    eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee patterns
  916.         match against the spawn    id defined at the time that
  917.         the eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee command was executed (not when its
  918.  
  919.  
  920.  
  921.      Page 14                        (printed 12/23/98)
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  929.  
  930.  
  931.  
  932.         pattern    is matched).
  933.  
  934.         The -info flag causes eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee to return the
  935.         current    specifications of what patterns    it will    match.
  936.         By default, it reports on the current spawn id.     An
  937.         optional spawn id specification    may be given for
  938.         information on that spawn id.  For example
  939.  
  940.             expect_before -info    -i $proc
  941.  
  942.         At most    one spawn id specification may be given.  The
  943.         flag -indirect suppresses direct spawn ids that    come
  944.         only from indirect specifications.
  945.  
  946.         Instead    of a spawn id specification, the flag "-all"
  947.         will cause "-info" to report on    all spawn ids.
  948.  
  949.         The output of the -info    flag can be reused as the
  950.         argument to expect_before.
  951.  
  952.       eeeexxxxppppeeeecccctttt____ttttttttyyyy [_e_x_p_e_c_t__a_r_g_s]
  953.         is like    eeeexxxxppppeeeecccctttt but it reads characters from /dev/tty
  954.         (i.e. keystrokes from the user).  By default, reading
  955.         is performed in    cooked mode.  Thus, lines must end
  956.         with a return in order for eeeexxxxppppeeeecccctttt to see them.    This
  957.         may be changed via ssssttttttttyyyy    (see the ssssttttttttyyyy command below).
  958.  
  959.       eeeexxxxppppeeeecccctttt____uuuusssseeeerrrr [_e_x_p_e_c_t__a_r_g_s]
  960.         is like    eeeexxxxppppeeeecccctttt but it reads characters from stdin
  961.         (i.e. keystrokes from the user).  By default, reading
  962.         is performed in    cooked mode.  Thus, lines must end
  963.         with a return in order for eeeexxxxppppeeeecccctttt to see them.    This
  964.         may be changed via ssssttttttttyyyy    (see the ssssttttttttyyyy command below).
  965.  
  966.       ffffoooorrrrkkkk    creates    a new process.    The new    process    is an exact
  967.         copy of    the current EEEExxxxppppeeeecccctttt process.  On    success, ffffoooorrrrkkkk
  968.         returns    0 to the new (child) process and returns the
  969.         process    ID of the child    process    to the parent process.
  970.         On failure (invariably due to lack of resources, e.g.,
  971.         swap space, memory), ffffoooorrrrkkkk returns -1 to    the parent
  972.         process, and no    child process is created.
  973.  
  974.         Forked processes exit via the eeeexxxxiiiitttt command, just like
  975.         the original process.  Forked processes    are allowed to
  976.         write to the log files.     If you    do not disable
  977.         debugging or logging in    most of    the processes, the
  978.         result can be confusing.
  979.  
  980.         Some pty implementations may be    confused by multiple
  981.         readers    and writers, even momentarily.    Thus, it is
  982.         safest to ffffoooorrrrkkkk before spawning processes.
  983.  
  984.  
  985.  
  986.  
  987.      Page 15                        (printed 12/23/98)
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  995.  
  996.  
  997.  
  998.       iiiinnnntttteeeerrrraaaacccctttt [_s_t_r_i_n_g_1 _b_o_d_y_1] ... [_s_t_r_i_n_g_n    [_b_o_d_y_n]]
  999.         gives control of the current process to    the user, so
  1000.         that keystrokes    are sent to the    current    process, and
  1001.         the stdout and stderr of the current process are
  1002.         returned.
  1003.  
  1004.         String-body pairs may be specified as arguments, in
  1005.         which case the body is executed    when the corresponding
  1006.         string is entered.  (By    default, the string is not
  1007.         sent to    the current process.)    The iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr
  1008.         command    is assumed, if the final body is missing.
  1009.  
  1010.         If the arguments to the    entire iiiinnnntttteeeerrrraaaacccctttt    statement
  1011.         require    more than one line, all    the arguments may be
  1012.         "braced" into one so as    to avoid terminating each line
  1013.         with a backslash.  In this one case, the usual Tcl
  1014.         substitutions will occur despite the braces.
  1015.  
  1016.         For example, the following command runs    interact with
  1017.         the following string-body pairs    defined:  When ^Z is
  1018.         pressed, EEEExxxxppppeeeecccctttt    is suspended.  (The ----rrrreeeesssseeeetttt flag
  1019.         restores the terminal modes.)  When ^A is pressed, the
  1020.         user sees "you typed a control-A" and the process is
  1021.         sent a ^A.  When $ is pressed, the user    sees the date.
  1022.         When ^C    is pressed, EEEExxxxppppeeeecccctttt exits.  If "foo" is
  1023.         entered, the user sees "bar".  When ~~ is pressed, the
  1024.         EEEExxxxppppeeeecccctttt interpreter runs    interactively.
  1025.  
  1026.             set    CTRLZ \032
  1027.             interact {
  1028.             -reset $CTRLZ {exec kill -STOP [pid]}
  1029.             \001   {send_user "you typed a control-A\n";
  1030.                 send "\001"
  1031.                    }
  1032.             $      {send_user "The date is [exec date]."}
  1033.             \003   exit
  1034.             foo    {send_user "bar"}
  1035.             ~~
  1036.             }
  1037.  
  1038.  
  1039.         In string-body pairs, strings are matched in the order
  1040.         they are listed    as arguments.  Strings that partially
  1041.         match are not sent to the current process in
  1042.         anticipation of    the remainder coming.  If characters
  1043.         are then entered such that there can no    longer
  1044.         possibly be a match, only the part of the string will
  1045.         be sent    to the process that cannot possibly begin
  1046.         another    match.    Thus, strings that are substrings of
  1047.         partial    matches    can match later, if the    original
  1048.         strings    that was attempting to be match    ultimately
  1049.         fails.
  1050.  
  1051.  
  1052.  
  1053.      Page 16                        (printed 12/23/98)
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1061.  
  1062.  
  1063.  
  1064.         By default, string matching is exact with no wild
  1065.         cards.    (In contrast, the eeeexxxxppppeeeecccctttt command uses glob-
  1066.         style patterns by default.)  The ----eeeexxxx flag may be used
  1067.         to protect patterns that might otherwise match
  1068.         iiiinnnntttteeeerrrraaaacccctttt flags from doing so.  Any pattern beginning
  1069.         with a "-" should be protected this way.    (All
  1070.         strings    starting with "-" are reserved for future
  1071.         options.)
  1072.  
  1073.         The ----rrrreeee    flag forces the    string to be interpreted as a
  1074.         regexp-style pattern.  In this case, matching
  1075.         substrings are stored in the variable _i_n_t_e_r_a_c_t__o_u_t
  1076.         similarly to the way eeeexxxxppppeeeecccctttt stores its output in the
  1077.         variable eeeexxxxppppeeeecccctttt____oooouuuutttt.  The ----iiiinnnnddddiiiicccceeeessss flag    is similarly
  1078.         supported.
  1079.  
  1080.         The pattern eeeeooooffff    introduces an action that is executed
  1081.         upon end-of-file.  A separate eeeeooooffff pattern may also
  1082.         follow the ----oooouuuuttttppppuuuutttt flag    in which case it is matched if
  1083.         an eof is detected while writing output.  The default
  1084.         eeeeooooffff action is "return",    so that    iiiinnnntttteeeerrrraaaacccctttt simply
  1085.         returns    upon any EOF.
  1086.  
  1087.         The pattern ttttiiiimmmmeeeeoooouuuutttt introduces a timeout (in seconds)
  1088.         and action that    is executed after no characters    have
  1089.         been read for a    given time.  The ttttiiiimmmmeeeeoooouuuutttt pattern
  1090.         applies    to the most recently specified process.     There
  1091.         is no default timeout.    The special variable "timeout"
  1092.         (used by the eeeexxxxppppeeeecccctttt command) has no affect on this
  1093.         timeout.
  1094.  
  1095.         For example, the following statement could be used to
  1096.         autologout users who have not typed anything for an
  1097.         hour but who still get frequent    system messages:
  1098.  
  1099.             interact -input $user_spawn_id timeout 3600    return -output \
  1100.             $spawn_id
  1101.  
  1102.  
  1103.         If the pattern is the keyword nnnnuuuullllllll, and    nulls are
  1104.         allowed    (via the rrrreeeemmmmoooovvvveeee____nnnnuuuullllllllssss command),    the
  1105.         corresponding body is executed if a single ASCII 0 is
  1106.         matched.  It is    not possible to    match 0    bytes via glob
  1107.         or regexp patterns.
  1108.  
  1109.         Prefacing a pattern with the flag ----iiiiwwwwrrrriiiitttteeee causes the
  1110.         variable _i_n_t_e_r_a_c_t__o_u_t(_s_p_a_w_n__i_d)    to be set to the
  1111.         spawn_id which matched the pattern (or eof).
  1112.  
  1113.         Actions    such as    bbbbrrrreeeeaaaakkkk and ccccoooonnnnttttiiiinnnnuuuueeee cause control
  1114.         structures (i.e., ffffoooorrrr, pppprrrroooocccc) to    behave in the usual
  1115.         way.  However rrrreeeettttuuuurrrrnnnn causes interact to    return to its
  1116.  
  1117.  
  1118.  
  1119.      Page 17                        (printed 12/23/98)
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1127.  
  1128.  
  1129.  
  1130.         caller,    while iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn causes iiiinnnntttteeeerrrraaaacccctttt to cause a
  1131.         return in its caller.  For example, if "proc foo"
  1132.         called iiiinnnntttteeeerrrraaaacccctttt    which then executed the    action
  1133.         iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn, pppprrrroooocccc ffffoooooooo would return.  (This means that
  1134.         if iiiinnnntttteeeerrrraaaacccctttt calls iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr interactively typing
  1135.         rrrreeeettttuuuurrrrnnnn will cause the interact to continue, while
  1136.         iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn will cause    the interact to    return to its
  1137.         caller.)
  1138.  
  1139.         During iiiinnnntttteeeerrrraaaacccctttt, raw mode is used so that all
  1140.         characters may be passed to the    current    process.  If
  1141.         the current process does not catch job control
  1142.         signals, it will stop if sent a    stop signal (by
  1143.         default    ^Z).  To restart it, send a continue signal
  1144.         (such as by "kill -CONT    <pid>").  If you really    want
  1145.         to send    a SIGSTOP to such a process (by    ^Z), consider
  1146.         spawning csh first and then running your program.  On
  1147.         the other hand,    if you want to send a SIGSTOP to
  1148.         EEEExxxxppppeeeecccctttt itself, first press the escape character, and
  1149.         then press ^Z.
  1150.  
  1151.         String-body pairs can be used as a shorthand for
  1152.         avoiding having    to enter the interpreter and execute
  1153.         commands interactively.     The previous terminal mode is
  1154.         used while the body of a string-body pair is being
  1155.         executed.
  1156.  
  1157.         For speed, actions execute in raw mode by default.
  1158.         The ----rrrreeeesssseeeetttt flag    resets the terminal to the mode    it had
  1159.         before iiiinnnntttteeeerrrraaaacccctttt    was executed (invariably, cooked
  1160.         mode).    Note that characters entered when the mode is
  1161.         being switched may be lost (an unfortunate feature of
  1162.         the terminal driver on some systems).  The only    reason
  1163.         to use ----rrrreeeesssseeeetttt is if your action    depends    on running in
  1164.         cooked mode.
  1165.  
  1166.         The ----eeeecccchhhhoooo flag sends characters    that match the
  1167.         following pattern back to the process that generated
  1168.         them as    each character is read.     This may be useful
  1169.         when the user needs to see feedback from partially
  1170.         typed patterns.
  1171.  
  1172.         If a pattern is    being echoed but eventually fails to
  1173.         match, the characters are sent to the spawned process.
  1174.         If the spawned process then echoes them, the user will
  1175.         see the    characters twice.  ----eeeecccchhhhoooo is probably only
  1176.         appropriate in situations where    the user is unlikely
  1177.         to not complete    the pattern.  For example, the
  1178.         following excerpt is from rftp,    the recursive-ftp
  1179.         script,    where the user is prompted to enter ~g,    ~p, or
  1180.         ~l, to get, put, or list the current directory
  1181.         recursively.  These are    so far away from the normal
  1182.  
  1183.  
  1184.  
  1185.      Page 18                        (printed 12/23/98)
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1193.  
  1194.  
  1195.  
  1196.         ftp commands, that the user is unlikely    to type    ~
  1197.         followed by anything else, except mistakenly, in which
  1198.         case, they'll probably just ignore the result anyway.
  1199.  
  1200.             interact {
  1201.             -echo ~g {getcurdirectory 1}
  1202.             -echo ~l {getcurdirectory 0}
  1203.             -echo ~p {putcurdirectory}
  1204.             }
  1205.  
  1206.         The ----nnnnoooobbbbuuuuffffffffeeeerrrr flag sends characters that match the
  1207.         following pattern on to    the output process as
  1208.         characters are read.
  1209.  
  1210.         This is    useful when you    wish to    let a program echo
  1211.         back the pattern.  For example,    the following might be
  1212.         used to    monitor    where a    person is dialing (a Hayes-
  1213.         style modem).  Each time "atd" is seen the script logs
  1214.         the rest of the    line.
  1215.  
  1216.             proc lognumber {} {
  1217.             interact -nobuffer -re "(.*)\r"    return
  1218.             puts $log "[exec date]:    dialed $interact_out(1,string)"
  1219.             }
  1220.  
  1221.             interact -nobuffer "atd" lognumber
  1222.  
  1223.  
  1224.         During iiiinnnntttteeeerrrraaaacccctttt, previous use of lllloooogggg____uuuusssseeeerrrr is ignored.
  1225.         In particular, iiiinnnntttteeeerrrraaaacccctttt    will force its output to be
  1226.         logged (sent to    the standard output) since it is
  1227.         presumed the user doesn't wish to interact blindly.
  1228.  
  1229.         The ----oooo flag causes any following key-body pairs    to be
  1230.         applied    to the output of the current process.  This
  1231.         can be useful, for example, when dealing with hosts
  1232.         that send unwanted characters during a telnet session.
  1233.  
  1234.         By default, iiiinnnntttteeeerrrraaaacccctttt expects the user to be writing
  1235.         stdin and reading stdout of the    EEEExxxxppppeeeecccctttt process itself.
  1236.         The ----uuuu flag (for "user") makes iiiinnnntttteeeerrrraaaacccctttt    look for the
  1237.         user as    the process named by its argument (which must
  1238.         be a spawned id).
  1239.  
  1240.         This allows two    unrelated processes to be joined
  1241.         together without using an explicit loop.  To aid in
  1242.         debugging, Expect diagnostics always go    to stderr (or
  1243.         stdout for certain logging and debugging information).
  1244.         For the    same reason, the iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr command will read
  1245.         interactively from stdin.
  1246.  
  1247.         For example, the following fragment creates a login
  1248.  
  1249.  
  1250.  
  1251.      Page 19                        (printed 12/23/98)
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1259.  
  1260.  
  1261.  
  1262.         process.  Then it dials    the user (not shown), and
  1263.         finally    connects the two together.  Of course, any
  1264.         process    may be substituted for login.  A shell,    for
  1265.         example, would allow the user to work without
  1266.         supplying an account and password.
  1267.  
  1268.             spawn login
  1269.             set    login $spawn_id
  1270.             spawn tip modem
  1271.             # dial back    out to user
  1272.             # connect user to login
  1273.             interact -u    $login
  1274.  
  1275.         To send    output to multiple processes, list each    spawn
  1276.         id list    prefaced by a ----oooouuuuttttppppuuuutttt flag.  Input for a group
  1277.         of output spawn    ids may    be determined by a spawn id
  1278.         list prefaced by a ----iiiinnnnppppuuuutttt flag.     (Both ----iiiinnnnppppuuuutttt and
  1279.         ----oooouuuuttttppppuuuutttt    may take lists in the same form    as the ----iiii flag
  1280.         in the eeeexxxxppppeeeecccctttt command, except that any_spawn_id    is not
  1281.         meaningful in iiiinnnntttteeeerrrraaaacccctttt.)  All following    flags and
  1282.         strings    (or patterns) apply to this input until
  1283.         another    -input flag appears.  If no ----iiiinnnnppppuuuutttt appears,
  1284.         ----oooouuuuttttppppuuuutttt    implies    "-input    $user_spawn_id -output".
  1285.         (Similarly, with patterns that do not have ----iiiinnnnppppuuuutttt.)
  1286.         If one ----iiiinnnnppppuuuutttt is specified, it overrides
  1287.         $user_spawn_id.     If a second ----iiiinnnnppppuuuutttt is specified, it
  1288.         overrides $spawn_id.  Additional ----iiiinnnnppppuuuutttt    flags may be
  1289.         specified.
  1290.  
  1291.         The two    implied    input processes    default    to having
  1292.         their outputs specified    as $spawn_id and
  1293.         $user_spawn_id (in reverse). If    a ----iiiinnnnppppuuuutttt flag appears
  1294.         with no    ----oooouuuuttttppppuuuutttt    flag, characters from that process are
  1295.         discarded.
  1296.  
  1297.         The ----iiii flag introduces a replacement for the current
  1298.         spawn_id when no other ----iiiinnnnppppuuuutttt or ----oooouuuuttttppppuuuutttt flags are
  1299.         used.  A -i flag implies a -o flag.
  1300.  
  1301.         It is possible to change the processes that are    being
  1302.         interacted with    by using indirect spawn    ids.
  1303.         (Indirect spawn    ids are    described in the section on
  1304.         the expect command.)  Indirect spawn ids may be
  1305.         specified with the -i, -u, -input, or -output flags.
  1306.  
  1307.       iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr
  1308.         causes the user    to be interactively prompted for
  1309.         EEEExxxxppppeeeecccctttt and Tcl commands.  The result of    each command
  1310.         is printed.
  1311.  
  1312.         Actions    such as    bbbbrrrreeeeaaaakkkk and ccccoooonnnnttttiiiinnnnuuuueeee cause control
  1313.         structures (i.e., ffffoooorrrr, pppprrrroooocccc) to    behave in the usual
  1314.  
  1315.  
  1316.  
  1317.      Page 20                        (printed 12/23/98)
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1325.  
  1326.  
  1327.  
  1328.         way.  However rrrreeeettttuuuurrrrnnnn causes interpreter    to return to
  1329.         its caller, while iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn causes iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr to
  1330.         cause a    return in its caller.  For example, if "proc
  1331.         foo" called iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr    which then executed the    action
  1332.         iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn, pppprrrroooocccc ffffoooooooo would return.  Any other
  1333.         command    causes iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr to continue prompting for
  1334.         new commands.
  1335.  
  1336.         By default, the    prompt contains    two integers.  The
  1337.         first integer describes    the depth of the evaluation
  1338.         stack (i.e., how many times Tcl_Eval has been called).
  1339.         The second integer is the Tcl history identifier.  The
  1340.         prompt can be set by defining a    procedure called
  1341.         "prompt1" whose    return value becomes the next prompt.
  1342.         If a statement has open    quotes,    parens,    braces,    or
  1343.         brackets, a secondary prompt (by default "+> ")    is
  1344.         issued upon newline.  The secondary prompt may be set
  1345.         by defining a procedure    called "prompt2".
  1346.  
  1347.         During iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr, cooked mode    is used, even if the
  1348.         its caller was using raw mode.
  1349.  
  1350.       lllloooogggg____ffffiiiilllleeee [_a_r_g_s] [[-_a]    _f_i_l_e]
  1351.         If a filename is provided, lllloooogggg____ffffiiiilllleeee will record    a
  1352.         transcript of the session (beginning at    that point) in
  1353.         the file.  lllloooogggg____ffffiiiilllleeee will stop recording    if no argument
  1354.         is given.  Any previous    log file is closed.
  1355.  
  1356.         Instead    of a filename, a Tcl file identifier may be
  1357.         provided by using the ----ooooppppeeeennnn or ----lllleeeeaaaavvvveeeeooooppppeeeennnn flags.  This
  1358.         is similar to the ssssppppaaaawwwwnnnn    command.  (See ssssppppaaaawwwwnnnn for more
  1359.         info.)
  1360.  
  1361.         The ----aaaa flag forces output to be    logged that was
  1362.         suppressed by the lllloooogggg____uuuusssseeeerrrr command.
  1363.  
  1364.         By default, the    lllloooogggg____ffffiiiilllleeee command _a_p_p_e_n_d_s to old    files
  1365.         rather than truncating them, for the convenience of
  1366.         being able to turn logging off and on multiple times
  1367.         in one session.     To truncate files, use    the ----nnnnooooaaaappppppppeeeennnndddd
  1368.         flag.
  1369.  
  1370.         The ----iiiinnnnffffoooo flag causes log_file to return a description
  1371.         of the most recent non-info arguments given.
  1372.  
  1373.       lllloooogggg____uuuusssseeeerrrr -_i_n_f_o|_0|_1
  1374.         By default, the    send/expect dialogue is    logged to
  1375.         stdout (and a logfile if open).     The logging to    stdout
  1376.         is disabled by the command "log_user 0"    and reenabled
  1377.         by "log_user 1".  Logging to the logfile is unchanged.
  1378.  
  1379.         The ----iiiinnnnffffoooo flag causes log_user to return a description
  1380.  
  1381.  
  1382.  
  1383.      Page 21                        (printed 12/23/98)
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1391.  
  1392.  
  1393.  
  1394.         of the most recent non-info arguments given.
  1395.  
  1396.       mmmmaaaattttcccchhhh____mmmmaaaaxxxx [-_d] [-_i _s_p_a_w_n__i_d] [_s_i_z_e]
  1397.         defines    the size of the    buffer (in bytes) used
  1398.         internally by eeeexxxxppppeeeecccctttt.  With no _s_i_z_e argument, the
  1399.         current    size is    returned.
  1400.  
  1401.         With the ----dddd flag, the default size is set.  (The
  1402.         initial    default    is 2000.)  With    the ----iiii flag, the size
  1403.         is set for the named spawn id, otherwise it is set for
  1404.         the current process.
  1405.  
  1406.       oooovvvveeeerrrrllllaaaayyyy [-# _s_p_a_w_n__i_d]    [-# _s_p_a_w_n__i_d] [...] _p_r_o_g_r_a_m [_a_r_g_s]
  1407.         executes _p_r_o_g_r_a_m _a_r_g_s in place of the current EEEExxxxppppeeeecccctttt
  1408.         program, which terminates.  A bare hyphen argument
  1409.         forces a hyphen    in front of the    command    name as    if it
  1410.         was a login shell.  All    spawn_ids are closed except
  1411.         for those named    as arguments.  These are mapped    onto
  1412.         the named file identifiers.
  1413.  
  1414.         Spawn_ids are mapped to    file identifiers for the new
  1415.         program    to inherit.  For example, the following    line
  1416.         runs chess and allows it to be controlled by the
  1417.         current    process    - say, a chess master.
  1418.  
  1419.             overlay -0 $spawn_id -1 $spawn_id -2 $spawn_id chess
  1420.  
  1421.         This is    more efficient than "interact -u", however, it
  1422.         sacrifices the ability to do programmed    interaction
  1423.         since the EEEExxxxppppeeeecccctttt process is no longer in control.
  1424.  
  1425.         Note that no controlling terminal is provided.    Thus,
  1426.         if you disconnect or remap standard input, programs
  1427.         that do    job control (shells, login, etc) will not
  1428.         function properly.
  1429.  
  1430.       ppppaaaarrrriiiittttyyyy [-_d] [-_i _s_p_a_w_n__i_d] [_v_a_l_u_e]
  1431.         defines    whether    parity should be retained or stripped
  1432.         from the output    of spawned processes.  If _v_a_l_u_e    is
  1433.         zero, parity is    stripped, otherwise it is not
  1434.         stripped.  With    no _v_a_l_u_e argument, the current value
  1435.         is returned.
  1436.  
  1437.         With the ----dddd flag, the default parity value is set.
  1438.         (The initial default is    1, i.e., parity    is not
  1439.         stripped.)  With the ----iiii    flag, the parity value is set
  1440.         for the    named spawn id,    otherwise it is    set for    the
  1441.         current    process.
  1442.  
  1443.       rrrreeeemmmmoooovvvveeee____nnnnuuuullllllllssss [-_d] [-_i    _s_p_a_w_n__i_d] [_v_a_l_u_e]
  1444.         defines    whether    nulls are retained or removed from the
  1445.         output of spawned processes before pattern matching or
  1446.  
  1447.  
  1448.  
  1449.      Page 22                        (printed 12/23/98)
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1457.  
  1458.  
  1459.  
  1460.         storing    in the variable    _e_x_p_e_c_t__o_u_t or _i_n_t_e_r_a_c_t__o_u_t.
  1461.         If _v_a_l_u_e is 1, nulls are removed.  If _v_a_l_u_e is 0,
  1462.         nulls are not removed.    With no    _v_a_l_u_e argument,    the
  1463.         current    value is returned.
  1464.  
  1465.         With the ----dddd flag, the default value is set.  (The
  1466.         initial    default    is 1, i.e., nulls are removed.)     With
  1467.         the ----iiii flag, the value is set for the named spawn id,
  1468.         otherwise it is    set for    the current process.
  1469.  
  1470.         Whether    or not nulls are removed, EEEExxxxppppeeeecccctttt will record
  1471.         null bytes to the log and stdout.
  1472.  
  1473.       sssseeeennnndddd [-_f_l_a_g_s]    _s_t_r_i_n_g
  1474.         Sends _s_t_r_i_n_g to    the current process.  For example, the
  1475.         command
  1476.  
  1477.             send "hello    world\r"
  1478.  
  1479.         sends the characters, h    e l l o    <blank>    w o r l    d
  1480.         <return> to the    current    process. (Tcl includes a
  1481.         printf-like command (called ffffoooorrrrmmmmaaaatttt) which can build
  1482.         arbitrarily complex strings.)
  1483.  
  1484.         Characters are sent immediately    although programs with
  1485.         line-buffered input will not read the characters until
  1486.         a return character is sent.  A return character    is
  1487.         denoted    "\r".
  1488.  
  1489.         The -------- flag forces the next argument to    be interpreted
  1490.         as a string rather than    a flag.     Any string can    be
  1491.         preceded by "--" whether or not    it actually looks like
  1492.         a flag.     This provides a reliable mechanism to specify
  1493.         variable strings without being tripped up by those
  1494.         that accidentally look like flags.  (All strings
  1495.         starting with "-" are reserved for future options.)
  1496.  
  1497.         The ----iiii flag declares that the string be    sent to    the
  1498.         named spawn_id.     If the    spawn_id is _u_s_e_r__s_p_a_w_n__i_d, and
  1499.         the terminal is    in raw mode, newlines in the string
  1500.         are translated to return-newline sequences so that
  1501.         they appear as it the terminal was in cooked mode.
  1502.         The ----rrrraaaawwww flag disables this translation.
  1503.  
  1504.         The ----nnnnuuuullllllll flag sends null characters (0    bytes).     By
  1505.         default, one null is sent.  An integer may follow the
  1506.         ----nnnnuuuullllllll to indicate how many nulls to send.
  1507.  
  1508.         The ----bbbbrrrreeeeaaaakkkk flag    generates a break condition.  This
  1509.         only makes sense if the    spawn id refers    to a tty
  1510.         device opened via "spawn -open".  If you have spawned
  1511.         a process such as tip, you should use tip's convention
  1512.  
  1513.  
  1514.  
  1515.      Page 23                        (printed 12/23/98)
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1523.  
  1524.  
  1525.  
  1526.         for generating a break.
  1527.  
  1528.         The ----ssss flag forces output to be    sent "slowly", thus
  1529.         avoid the common situation where a computer outtypes
  1530.         an input buffer    that was designed for a    human who
  1531.         would never outtype the    same buffer.  This output is
  1532.         controlled by the value    of the variable    "send_slow"
  1533.         which takes a two element list.     The first element is
  1534.         an integer that    describes the number of    bytes to send
  1535.         atomically.  The second    element    is a real number that
  1536.         describes the number of    seconds    by which the atomic
  1537.         sends must be separated.  For example, "set send_slow
  1538.         {10 .001}" would force "send -s" to send strings with
  1539.         1 millisecond in between each 10 characters sent.
  1540.  
  1541.         The ----hhhh flag forces output to be    sent (somewhat)    like a
  1542.         human actually typing.    Human-like delays appear
  1543.         between    the characters.     (The algorithm    is based upon
  1544.         a Weibull distribution,    with modifications to suit
  1545.         this particular    application.)  This output is
  1546.         controlled by the value    of the variable    "send_human"
  1547.         which takes a five element list.  The first two
  1548.         elements are average interarrival time of characters
  1549.         in seconds.  The first is used by default.  The    second
  1550.         is used    at word    endings, to simulate the subtle    pauses
  1551.         that occasionally occur    at such    transitions.  The
  1552.         third parameter    is a measure of    variability where .1
  1553.         is quite variable, 1 is    reasonably variable, and 10 is
  1554.         quite invariable.  The extremes    are 0 to infinity.
  1555.         The last two parameters    are, respectively, a minimum
  1556.         and maximum interarrival time.    The minimum and
  1557.         maximum    are used last and "clip" the final time.  The
  1558.         ultimate average can be    quite different    from the given
  1559.         average    if the minimum and maximum clip    enough values.
  1560.  
  1561.         As an example, the following command emulates a    fast
  1562.         and consistent typist:
  1563.  
  1564.             set    send_human {.1 .3 1 .05    2}
  1565.             send -h "I'm hungry.  Let's    do lunch."
  1566.  
  1567.         while the following might be more suitable after a
  1568.         hangover:
  1569.  
  1570.             set    send_human {.4 .4 .2 .5    100}
  1571.             send -h "Goodd party lash night!"
  1572.  
  1573.         Note that errors are not simulated, although you can
  1574.         set up error correction    situations yourself by
  1575.         embedding mistakes and corrections in a    send argument.
  1576.  
  1577.         The flags for sending null characters, for sending
  1578.  
  1579.  
  1580.  
  1581.      Page 24                        (printed 12/23/98)
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1589.  
  1590.  
  1591.  
  1592.         breaks,    for forcing slow output    and for    human-style
  1593.         output are mutually exclusive. Only the    one specified
  1594.         last will be used. Furthermore,    no _s_t_r_i_n_g argument can
  1595.         be specified with the flags for    sending    null
  1596.         characters or breaks.
  1597.  
  1598.         It is a    good idea to precede the first sssseeeennnndddd to a
  1599.         process    by an eeeexxxxppppeeeecccctttt.  eeeexxxxppppeeeecccctttt will wait    for the
  1600.         process    to start, while    sssseeeennnndddd cannot.  In particular,
  1601.         if the first sssseeeennnndddd completes before the process starts
  1602.         running, you run the risk of having your data ignored.
  1603.         In situations where interactive    programs offer no
  1604.         initial    prompt,    you can    precede    sssseeeennnndddd by    a delay    as in:
  1605.  
  1606.             # To avoid giving hackers hints on how to break in,
  1607.             # this system does not prompt for an external password.
  1608.             # Wait for 5 seconds for exec to complete
  1609.             spawn telnet very.secure.gov
  1610.             sleep 5
  1611.             send password\r
  1612.  
  1613.         eeeexxxxpppp____sssseeeennnndddd is an alias for sssseeeennnndddd.    If you are using
  1614.         Expectk    or some    other variant of Expect    in the Tk
  1615.         environment, sssseeeennnndddd is defined by    Tk for an entirely
  1616.         different purpose.  eeeexxxxpppp____sssseeeennnndddd is    provided for
  1617.         compatibility between environments.  Similar aliases
  1618.         are provided for other Expect's    other send commands.
  1619.  
  1620.       sssseeeennnndddd____eeeerrrrrrrroooorrrr [-_f_l_a_g_s] _s_t_r_i_n_g
  1621.         is like    sssseeeennnndddd, except that the output is    sent to    stderr
  1622.         rather than the    current    process.
  1623.  
  1624.       sssseeeennnndddd____lllloooogggg [--]    _s_t_r_i_n_g
  1625.         is like    sssseeeennnndddd, except that the string is    only sent to
  1626.         the log    file (see lllloooogggg____ffffiiiilllleeee.)  The arguments are
  1627.         ignored    if no log file is open.
  1628.  
  1629.       sssseeeennnndddd____ttttttttyyyy [-_f_l_a_g_s] _s_t_r_i_n_g
  1630.         is like    sssseeeennnndddd, except that the output is    sent to
  1631.         /dev/tty rather    than the current process.
  1632.  
  1633.       sssseeeennnndddd____uuuusssseeeerrrr [-_f_l_a_g_s] _s_t_r_i_n_g
  1634.         is like    sssseeeennnndddd, except that the output is    sent to    stdout
  1635.         rather than the    current    process.
  1636.  
  1637.       sssslllleeeeeeeepppp    _s_e_c_o_n_d_s
  1638.         causes the script to sleep for the given number    of
  1639.         seconds.  Seconds may be a decimal number.  Interrupts
  1640.         (and Tk    events if you are using    Expectk) are processed
  1641.         while Expect sleeps.
  1642.  
  1643.       ssssppppaaaawwwwnnnn    [_a_r_g_s] _p_r_o_g_r_a_m [_a_r_g_s]
  1644.  
  1645.  
  1646.  
  1647.      Page 25                        (printed 12/23/98)
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1655.  
  1656.  
  1657.  
  1658.         creates    a new process running _p_r_o_g_r_a_m _a_r_g_s.  Its
  1659.         stdin, stdout and stderr are connected to Expect, so
  1660.         that they may be read and written by other EEEExxxxppppeeeecccctttt
  1661.         commands.  The connection is broken by cccclllloooosssseeee or    if the
  1662.         process    itself closes any of the file identifiers.
  1663.  
  1664.         When a process is started by ssssppppaaaawwwwnnnn, the    variable
  1665.         _s_p_a_w_n__i_d is set    to a descriptor    referring to that
  1666.         process.  The process described    by _s_p_a_w_n__i_d is
  1667.         considered the _c_u_r_r_e_n_t _p_r_o_c_e_s_s.     _s_p_a_w_n__i_d may be read
  1668.         or written, in effect providing    job control.
  1669.  
  1670.         _u_s_e_r__s_p_a_w_n__i_d is a global variable containing a
  1671.         descriptor which refers    to the user.  For example,
  1672.         when _s_p_a_w_n__i_d is set to    this value, eeeexxxxppppeeeecccctttt behaves
  1673.         like eeeexxxxppppeeeecccctttt____uuuusssseeeerrrr.
  1674.  
  1675.         _e_r_r_o_r__s_p_a_w_n__i_d is a global variable containing a
  1676.         descriptor which refers    to the standard    error.    For
  1677.         example, when _s_p_a_w_n__i_d is set to this value, sssseeeennnndddd
  1678.         behaves    like sssseeeennnndddd____eeeerrrrrrrroooorrrr.
  1679.  
  1680.         _t_t_y__s_p_a_w_n__i_d is    a global variable containing a
  1681.         descriptor which refers    to /dev/tty.  If /dev/tty does
  1682.         not exist (such    as in a    cron, at, or batch script),
  1683.         then _t_t_y__s_p_a_w_n__i_d is not defined.  This    may be tested
  1684.         as:
  1685.  
  1686.             if [info vars tty_spawn_id]    {
  1687.             # /dev/tty exists
  1688.             } else {
  1689.             # /dev/tty doesn't exist
  1690.             # probably in cron, batch, or at script
  1691.             }
  1692.  
  1693.  
  1694.         ssssppppaaaawwwwnnnn returns the UNIX process id.  If no process is
  1695.         spawned, 0 is returned.     The variable
  1696.         _s_p_a_w_n__o_u_t(_s_l_a_v_e,_n_a_m_e) is set to    the name of the    pty
  1697.         slave device.
  1698.  
  1699.         By default, ssssppppaaaawwwwnnnn echoes the command name and
  1700.         arguments.  The    ----nnnnooooeeeecccchhhhoooo    flag stops ssssppppaaaawwwwnnnn from doing
  1701.         this.
  1702.  
  1703.         The ----ccccoooonnnnssssoooolllleeee flag causes console output    to be
  1704.         redirected to the spawned process.  This is not
  1705.         supported on all systems.
  1706.  
  1707.         Internally, ssssppppaaaawwwwnnnn uses a pty, initialized the same way
  1708.         as the user's tty.  This is further initialized    so
  1709.         that all settings are "sane" (according    to stty(1)).
  1710.  
  1711.  
  1712.  
  1713.      Page 26                        (printed 12/23/98)
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1721.  
  1722.  
  1723.  
  1724.         If the variable    _s_t_t_y__i_n_i_t is defined, it is
  1725.         interpreted in the style of stty arguments as further
  1726.         configuration.    For example, "set stty_init raw" will
  1727.         cause further spawned processes's terminals to start
  1728.         in raw mode.  ----nnnnoooottttttttyyyyccccooooppppyyyy skips the initialization
  1729.         based on the user's tty.  ----nnnnoooottttttttyyyyiiiinnnniiiitttt skips the "sane"
  1730.         initialization.
  1731.  
  1732.         Normally, ssssppppaaaawwwwnnnn    takes little time to execute.  If you
  1733.         notice spawn taking a significant amount of time, it
  1734.         is probably encountering ptys that are wedged.    A
  1735.         number of tests    are run    on ptys    to avoid entanglements
  1736.         with errant processes.    (These take 10 seconds per
  1737.         wedged pty.)  Running Expect with the ----dddd option    will
  1738.         show if    EEEExxxxppppeeeecccctttt is encountering many ptys in odd
  1739.         states.     If you    cannot kill the    processes to which
  1740.         these ptys are attached, your only recourse may    be to
  1741.         reboot.
  1742.  
  1743.         If _p_r_o_g_r_a_m cannot be spawned successfully because
  1744.         exec(2)    fails (e.g. when _p_r_o_g_r_a_m doesn't exist), an
  1745.         error message will be returned by the next iiiinnnntttteeeerrrraaaacccctttt or
  1746.         eeeexxxxppppeeeecccctttt command as if _p_r_o_g_r_a_m had run and produced the
  1747.         error message as output.  This behavior    is a natural
  1748.         consequence of the implementation of ssssppppaaaawwwwnnnn.
  1749.         Internally, spawn forks, after which the spawned
  1750.         process    has no way to communicate with the original
  1751.         EEEExxxxppppeeeecccctttt process except by communication via the
  1752.         spawn_id.
  1753.  
  1754.         The ----ooooppppeeeennnn flag causes the next argument    to be
  1755.         interpreted as a Tcl file identifier (i.e., returned
  1756.         by ooooppppeeeennnn.)  The spawn id    can then be used as if it were
  1757.         a spawned process.  (The file identifier should    no
  1758.         longer be used.)  This lets you    treat raw devices,
  1759.         files, and pipelines as    spawned    processes without
  1760.         using a    pty.  0    is returned to indicate    there is no
  1761.         associated process.  When the connection to the
  1762.         spawned    process    is closed, so is the Tcl file
  1763.         identifier.  The ----lllleeeeaaaavvvveeeeooooppppeeeennnn flag is similar to ----ooooppppeeeennnn
  1764.         except that ----lllleeeeaaaavvvveeeeooooppppeeeennnn causes the file identifier to
  1765.         be left    open even after    the spawn id is    closed.
  1766.  
  1767.         The ----ppppttttyyyy flag causes a pty to be opened    but no process
  1768.         spawned.  0 is returned    to indicate there is no
  1769.         associated process.  Spawn_id is set as    usual.
  1770.  
  1771.         The variable _s_p_a_w_n__o_u_t(_s_l_a_v_e,_f_d) is set    to a file
  1772.         identifier corresponding to the    pty slave.  It can be
  1773.         closed using "close -slave".
  1774.  
  1775.         The ----iiiiggggnnnnoooorrrreeee flag names a signal    to be ignored in the
  1776.  
  1777.  
  1778.  
  1779.      Page 27                        (printed 12/23/98)
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1787.  
  1788.  
  1789.  
  1790.         spawned    process.  Otherwise, signals get the default
  1791.         behavior.  Signals are named as    in the ttttrrrraaaapppp command,
  1792.         except that each signal    requires a separate flag.
  1793.  
  1794.       ssssttttrrrraaaacccceeee _l_e_v_e_l
  1795.         causes following statements to be printed before being
  1796.         executed.  (Tcl's trace    command    traces variables.)
  1797.         _l_e_v_e_l indicates    how far    down in    the call stack to
  1798.         trace.    For example, the following command runs    EEEExxxxppppeeeecccctttt
  1799.         while tracing the first    4 levels of calls, but none
  1800.         below that.
  1801.  
  1802.             expect -c "strace 4" script.exp
  1803.  
  1804.  
  1805.         The ----iiiinnnnffffoooo flag causes strace to    return a description
  1806.         of the most recent non-info arguments given.
  1807.  
  1808.       ssssttttttttyyyy _a_r_g_s
  1809.         changes    terminal modes similarly to the    external stty
  1810.         command.
  1811.  
  1812.         By default, the    controlling terminal is    accessed.
  1813.         Other terminals    can be accessed    by appending "<
  1814.         /dev/tty..." to    the command.  (Note that the arguments
  1815.         should not be grouped into a single argument.)
  1816.  
  1817.         Requests for status return it as the result of the
  1818.         command.  If no    status is requested and    the
  1819.         controlling terminal is    accessed, the previous status
  1820.         of the raw and echo attributes are returned in a form
  1821.         which can later    be used    by the command.
  1822.  
  1823.         For example, the arguments rrrraaaawwww or ----ccccooooooookkkkeeeedddd put the
  1824.         terminal into raw mode.     The arguments ----rrrraaaawwww or ccccooooooookkkkeeeedddd
  1825.         put the    terminal into cooked mode.  The    arguments eeeecccchhhhoooo
  1826.         and ----eeeecccchhhhoooo put the terminal into    echo and noecho    mode
  1827.         respectively.
  1828.  
  1829.         The following example illustrates how to temporarily
  1830.         disable    echoing.  This could be    used in    otherwise-
  1831.         automatic scripts to avoid embedding passwords in
  1832.         them.  (See more discussion on this under EXPECT HINTS
  1833.         below.)
  1834.  
  1835.             stty -echo
  1836.             send_user "Password: "
  1837.             expect_user    -re "(.*)\n"
  1838.             set    password $expect_out(1,string)
  1839.             stty echo
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.      Page 28                        (printed 12/23/98)
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1853.  
  1854.  
  1855.  
  1856.       ssssyyyysssstttteeeemmmm _a_r_g_s
  1857.         gives _a_r_g_s to sh(1) as input, just as if it had    been
  1858.         typed as a command from    a terminal.  EEEExxxxppppeeeecccctttt waits
  1859.         until the shell    terminates.  The return    status from sh
  1860.         is handled the same way    that eeeexxxxeeeecccc handles its return
  1861.         status.
  1862.  
  1863.         In contrast to eeeexxxxeeeecccc which redirects stdin and stdout
  1864.         to the script, ssssyyyysssstttteeeemmmm performs no redirection (other
  1865.         than that indicated by the string itself).  Thus, it
  1866.         is possible to use programs which must talk directly
  1867.         to /dev/tty.  For the same reason, the results of
  1868.         ssssyyyysssstttteeeemmmm are not recorded    in the log.
  1869.  
  1870.       ttttiiiimmmmeeeessssttttaaaammmmpppp [_a_r_g_s]
  1871.         returns    a timestamp.  With no arguments, the number of
  1872.         seconds    since the epoch    is returned.
  1873.  
  1874.         The ----ffffoooorrrrmmmmaaaatttt flag introduces a string which is returned
  1875.         but with substitutions made according to the POSIX
  1876.         rules for strftime.  For example %a is replaced    by an
  1877.         abbreviated weekday name (i.e.,    Sat).  Others are:
  1878.             %a        abbreviated    weekday    name
  1879.             %A        full weekday name
  1880.             %b        abbreviated    month name
  1881.             %B        full month name
  1882.             %c        date-time as in: Wed Oct  6    11:45:56 1993
  1883.             %d        day    of the month (01-31)
  1884.             %H        hour (00-23)
  1885.             %I        hour (01-12)
  1886.             %j        day    (001-366)
  1887.             %m        month (01-12)
  1888.             %M        minute (00-59)
  1889.             %p        am or pm
  1890.             %S        second (00-61)
  1891.             %u        day    (1-7, Monday is    first day of week)
  1892.             %U        week (00-53, first Sunday is first day of week one)
  1893.             %V        week (01-53, ISO 8601 style)
  1894.             %w        day    (0-6)
  1895.             %W        week (00-53, first Monday is first day of week one)
  1896.             %x        date-time as in: Wed Oct  6    1993
  1897.             %X        time as in:    23:59:59
  1898.             %y        year (00-99)
  1899.             %Y        year as in:    1993
  1900.             %Z        timezone (or nothing if not    determinable)
  1901.             %%        a bare percent sign
  1902.  
  1903.         Other %    specifications are undefined.  Other
  1904.         characters will    be passed through untouched.  Only the
  1905.         C locale is supported.
  1906.  
  1907.         The ----sssseeeeccccoooonnnnddddssss flag introduces a number of seconds since
  1908.  
  1909.  
  1910.  
  1911.      Page 29                        (printed 12/23/98)
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1919.  
  1920.  
  1921.  
  1922.         the epoch to be    used as    a source from which to format.
  1923.         Otherwise, the current time is used.
  1924.  
  1925.         The ----ggggmmmmtttt flag forces timestamp output to use the GMT
  1926.         timezone.  With    no flag, the local timezone is used.
  1927.  
  1928.       ttttrrrraaaapppp [[_c_o_m_m_a_n_d] _s_i_g_n_a_l_s]
  1929.         causes the given _c_o_m_m_a_n_d to be executed    upon future
  1930.         receipt    of any of the given signals.  The command is
  1931.         executed in the    global scope.  If _c_o_m_m_a_n_d is absent,
  1932.         the signal action is returned.    If _c_o_m_m_a_n_d is the
  1933.         string SIG_IGN,    the signals are    ignored.  If _c_o_m_m_a_n_d
  1934.         is the string SIG_DFL, the signals are result to the
  1935.         system default.     _s_i_g_n_a_l_s is either a single signal or
  1936.         a list of signals.  Signals may    be specified
  1937.         numerically or symbolically as per signal(3).  The
  1938.         "SIG" prefix may be omitted.
  1939.  
  1940.         With no    arguments (or the argument -number), ttttrrrraaaapppp
  1941.         returns    the signal number of the trap command
  1942.         currently being    executed.
  1943.  
  1944.         The ----ccccooooddddeeee flag uses the    return code of the command in
  1945.         place of whatever code Tcl was about to    return when
  1946.         the command originally started running.
  1947.  
  1948.         The ----iiiinnnntttteeeerrrrpppp flag causes    the command to be evaluated
  1949.         using the interpreter active at    the time the command
  1950.         started    running    rather than when the trap was
  1951.         declared.
  1952.  
  1953.         The ----nnnnaaaammmmeeee flag causes the ttttrrrraaaapppp command to return the
  1954.         signal name of the trap    command    currently being
  1955.         executed.
  1956.  
  1957.         The ----mmmmaaaaxxxx flag causes the ttttrrrraaaapppp command to return    the
  1958.         largest    signal number that can be set.
  1959.  
  1960.         For example, the command "trap {send_user "Ouch!"}
  1961.         SIGINT"    will print "Ouch!"  each time the user presses
  1962.         ^C.
  1963.  
  1964.         By default, SIGINT (which can usually be generated by
  1965.         pressing ^C) and SIGTERM cause Expect to exit.    This
  1966.         is due to the following    trap, created by default when
  1967.         Expect starts.
  1968.  
  1969.             trap exit {SIGINT SIGTERM}
  1970.  
  1971.         If you use the -D flag to start    the debugger, SIGINT
  1972.         is redefined to    start the interactive debugger.     This
  1973.         is due to the following    trap:
  1974.  
  1975.  
  1976.  
  1977.      Page 30                        (printed 12/23/98)
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1985.  
  1986.  
  1987.  
  1988.             trap {exp_debug 1} SIGINT
  1989.  
  1990.         The debugger trap can be changed by setting the
  1991.         environment variable EXPECT_DEBUG_INIT to a new    trap
  1992.         command.
  1993.  
  1994.         You can, of course, override both of these just    by
  1995.         adding trap commands to    your script.  In particular,
  1996.         if you have your own "trap exit    SIGINT", this will
  1997.         override the debugger trap.  This is useful if you
  1998.         want to    prevent    users from getting to the debugger at
  1999.         all.
  2000.  
  2001.         If you want to define your own trap on SIGINT but
  2002.         still trap to the debugger when    it is running, use:
  2003.  
  2004.             if ![exp_debug] {trap mystuff SIGINT}
  2005.  
  2006.         Alternatively, you can trap to the debugger using some
  2007.         other signal.
  2008.  
  2009.         ttttrrrraaaapppp will not let you override the action for SIGALRM
  2010.         as this    is used    internally to EEEExxxxppppeeeecccctttt.  The disconnect
  2011.         command    sets SIGALRM to    SIG_IGN    (ignore).  You can
  2012.         reenable this as long as you disable it    during
  2013.         subsequent spawn commands.
  2014.  
  2015.         See signal(3) for more info.
  2016.  
  2017.       wwwwaaaaiiiitttt [_a_r_g_s]
  2018.         delays until a spawned process (or the current process
  2019.         if none    is named) terminates.
  2020.  
  2021.         wwwwaaaaiiiitttt normally returns a    list of    four integers.    The
  2022.         first integer is the pid of the    process    that was
  2023.         waited upon.  The second integer is the    corresponding
  2024.         spawn id.  The third integer is    -1 if an operating
  2025.         system error occurred, or 0 otherwise.    If the third
  2026.         integer    was 0, the fourth integer is the status
  2027.         returned by the    spawned    process.  If the third integer
  2028.         was -1,    the fourth integer is the value    of errno set
  2029.         by the operating system.  The global variable
  2030.         errorCode is also set.
  2031.  
  2032.         Additional elements may    appear at the end of the
  2033.         return value from wwwwaaaaiiiitttt.     An optional fifth element
  2034.         identifies a class of information.  Currently, the
  2035.         only possible value for    this element is    CHILDKILLED in
  2036.         which case the next two    values are the C-style signal
  2037.         name and a short textual description.
  2038.  
  2039.         The ----iiii flag declares the process to wait corresponding
  2040.  
  2041.  
  2042.  
  2043.      Page 31                        (printed 12/23/98)
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2051.  
  2052.  
  2053.  
  2054.         to the named spawn_id (NOT the process id).  Inside a
  2055.         SIGCHLD    handler, it is possible    to wait    for any
  2056.         spawned    process    by using the spawn id -1.
  2057.  
  2058.         The ----nnnnoooowwwwaaaaiiiitttt flag causes    the wait to return immediately
  2059.         with the indication of a successful wait.  When    the
  2060.         process    exits (later), it will automatically disappear
  2061.         without    the need for an    explicit wait.
  2062.  
  2063.         The wwwwaaaaiiiitttt command may also be used wait for a forked
  2064.         process    using the arguments "-i    -1".  Unlike its use
  2065.         with spawned processes,    this command can be executed
  2066.         at any time.  There is no control over which process
  2067.         is reaped.  However, the return    value can be checked
  2068.         for the    process    id.
  2069.  
  2070.  
  2071.      LLLLIIIIBBBBRRRRAAAARRRRIIIIEEEESSSS
  2072.       Expect automatically knows about two built-in    libraries for
  2073.       Expect scripts.  These are defined by    the directories    named
  2074.       in the variables exp_library and exp_exec_library.  Both are
  2075.       meant    to contain utility files that can be used by other
  2076.       scripts.
  2077.  
  2078.       exp_library contains architecture-independent    files.
  2079.       exp_exec_library contains architecture-dependent files.
  2080.       Depending on your system, both directories may be totally
  2081.       empty.  The existence    of the file $exp_exec_library/cat-
  2082.       buffers describes whether your /bin/cat buffers by default.
  2083.  
  2084.      PPPPRRRREEEETTTTTTTTYYYY----PPPPRRRRIIIINNNNTTTTIIIINNNNGGGG
  2085.       A vgrind definition is available for pretty-printing EEEExxxxppppeeeecccctttt
  2086.       scripts.  Assuming the vgrind    definition supplied with the
  2087.       EEEExxxxppppeeeecccctttt distribution is correctly installed, you can use it
  2088.       as:
  2089.  
  2090.           vgrind -lexpect file
  2091.  
  2092.  
  2093.      EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  2094.       It many not be apparent how to put everything    together that
  2095.       the man page describes.  I encourage you to read and try out
  2096.       the examples in the example directory    of the EEEExxxxppppeeeecccctttt
  2097.       distribution.     Some of them are real programs.  Others are
  2098.       simply illustrative of certain techniques, and of course, a
  2099.       couple are just quick    hacks.    The INSTALL file has a quick
  2100.       overview of these programs.
  2101.  
  2102.       The EEEExxxxppppeeeecccctttt papers (see SEE ALSO) are also useful.  While
  2103.       some papers use syntax corresponding to earlier versions of
  2104.       Expect, the accompanying rationales are still    valid and go
  2105.       into a lot more detail than this man page.
  2106.  
  2107.  
  2108.  
  2109.      Page 32                        (printed 12/23/98)
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2117.  
  2118.  
  2119.  
  2120.      CCCCAAAAVVVVEEEEAAAATTTTSSSS
  2121.       Extensions may collide with Expect's command names.  For
  2122.       example, sssseeeennnndddd    is defined by Tk for an    entirely different
  2123.       purpose.  For    this reason, most of the EEEExxxxppppeeeecccctttt    commands are
  2124.       also available as "exp_XXXX".     Commands and variables
  2125.       beginning with "exp",    "inter", "spawn", and "timeout"    do not
  2126.       have aliases.     Use the extended command names    if you need
  2127.       this compatibility between environments.
  2128.  
  2129.       EEEExxxxppppeeeecccctttt takes a rather    liberal    view of    scoping.  In
  2130.       particular, variables    read by    commands specific to the
  2131.       EEEExxxxppppeeeecccctttt program will be sought    first from the local scope,
  2132.       and if not found, in the global scope.  For example, this
  2133.       obviates the need to place "global timeout" in every
  2134.       procedure you    write that uses    eeeexxxxppppeeeecccctttt.     On the    other hand,
  2135.       variables written are    always in the local scope (unless a
  2136.       "global" command has been issued).  The most common problem
  2137.       this causes is when spawn is executed    in a procedure.
  2138.       Outside the procedure, _s_p_a_w_n__i_d no longer exists, so the
  2139.       spawned process is no    longer accessible simply because of
  2140.       scoping.  Add    a "global spawn_id" to such a procedure.
  2141.  
  2142.       If you cannot    enable the multispawning capability (i.e.,
  2143.       your system supports neither select (BSD *.*), poll (SVR>2),
  2144.       nor something    equivalent), EEEExxxxppppeeeecccctttt will only be able to
  2145.       control a single process at a    time.  In this case, do    not
  2146.       attempt to set _s_p_a_w_n__i_d, nor should you execute processes
  2147.       via exec while a spawned process is running.    Furthermore,
  2148.       you will not be able to eeeexxxxppppeeeecccctttt from multiple processes
  2149.       (including the user as one) at the same time.
  2150.  
  2151.       Terminal parameters can have a big effect on scripts.     For
  2152.       example, if a    script is written to look for echoing, it will
  2153.       misbehave if echoing is turned off.  For this    reason,    Expect
  2154.       forces sane terminal parameters by default.  Unfortunately,
  2155.       this can make    things unpleasant for other programs.  As an
  2156.       example, the emacs shell wants to change the "usual"
  2157.       mappings: newlines get mapped    to newlines instead of
  2158.       carriage-return newlines, and    echoing    is disabled.  This
  2159.       allows one to    use emacs to edit the input line.
  2160.       Unfortunately, Expect    cannot possibly    guess this.
  2161.  
  2162.       You can request that Expect not override its default setting
  2163.       of terminal parameters, but you must then be very careful
  2164.       when writing scripts for such    environments.  In the case of
  2165.       emacs, avoid depending upon things like echoing and end-of-
  2166.       line mappings.
  2167.  
  2168.       The commands that accepted arguments braced into a single
  2169.       list (the eeeexxxxppppeeeecccctttt variants and    iiiinnnntttteeeerrrraaaacccctttt) use a    heuristic to
  2170.       decide if the    list is    actually one argument or many.    The
  2171.       heuristic can    fail only in the case when the list actually
  2172.  
  2173.  
  2174.  
  2175.      Page 33                        (printed 12/23/98)
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2183.  
  2184.  
  2185.  
  2186.       does represent a single argument which has multiple embedded
  2187.       \n's with non-whitespace characters between them.  This
  2188.       seems    sufficiently improbable, however the argument "-brace"
  2189.       can be used to force a single    argument to be handled as a
  2190.       single argument.  This could conceivably be used with
  2191.       machine-generated Expect code.
  2192.  
  2193.      BBBBUUUUGGGGSSSS
  2194.       It was really    tempting to name the program "sex" (for    either
  2195.       "Smart EXec" or "Send-EXpect"), but good sense (or perhaps
  2196.       just Puritanism) prevailed.
  2197.  
  2198.       On some systems, when    a shell    is spawned, it complains about
  2199.       not being able to access the tty but runs anyway.  This
  2200.       means    your system has    a mechanism for    gaining    the
  2201.       controlling tty that EEEExxxxppppeeeecccctttt doesn't know about.  Please find
  2202.       out what it is, and send this    information back to me.
  2203.  
  2204.       Ultrix 4.1 (at least the latest versions around here)
  2205.       considers timeouts of    above 1000000 to be equivalent to 0.
  2206.  
  2207.       Digital UNIX 4.0A (and probably other    versions) refuses to
  2208.       allocate ptys    if you define a    SIGCHLD    handler.  See grantpt
  2209.       page for more    info.
  2210.  
  2211.       IRIX 6.0 does    not handle pty permissions correctly so    that
  2212.       if Expect attempts to    allocate a pty previously used by
  2213.       someone else,    it fails.  Upgrade to IRIX 6.1.
  2214.  
  2215.       Telnet (verified only    under SunOS 4.1.2) hangs if TERM is
  2216.       not set.  This is a problem under cron, at and in cgi
  2217.       scripts, which do not    define TERM.  Thus, you    must set it
  2218.       explicitly - to what type is usually irrelevant.  It just
  2219.       has to be set    to something!  The following probably suffices
  2220.       for most cases.
  2221.  
  2222.           set env(TERM) vt100
  2223.  
  2224.  
  2225.       Tip (verified    only under BSDI    BSD/OS 3.1 i386) hangs if
  2226.       SHELL    and HOME are not set.  This is a problem under cron,
  2227.       at and in cgi    scripts, which do not define these environment
  2228.       variables.  Thus, you    must set them explicitly - to what
  2229.       type is usually irrelevant.  It just has to be set to
  2230.       something!  The following probably suffices for most cases.
  2231.  
  2232.           set env(SHELL) /bin/sh
  2233.           set env(HOME) /usr/local/bin
  2234.  
  2235.  
  2236.  
  2237.       Some implementations of ptys are designed so that the    kernel
  2238.  
  2239.  
  2240.  
  2241.      Page 34                        (printed 12/23/98)
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2249.  
  2250.  
  2251.  
  2252.       throws away any unread output    after 10 to 15 seconds (actual
  2253.       number is implementation-dependent) after the    process    has
  2254.       closed the file descriptor.  Thus EEEExxxxppppeeeecccctttt programs such as
  2255.  
  2256.           spawn date
  2257.           sleep 20
  2258.           expect
  2259.  
  2260.       will fail.  To avoid this, invoke non-interactive programs
  2261.       with eeeexxxxeeeecccc rather than    ssssppppaaaawwwwnnnn.    While such situations are
  2262.       conceivable, in practice I have never    encountered a
  2263.       situation in which the final output of a truly interactive
  2264.       program would    be lost    due to this behavior.
  2265.  
  2266.       On the other hand, Cray UNICOS ptys throw away any unread
  2267.       output immediately after the process has closed the file
  2268.       descriptor.  I have reported this to Cray and    they are
  2269.       working on a fix.
  2270.  
  2271.       Sometimes a delay is required    between    a prompt and a
  2272.       response, such as when a tty interface is changing UART
  2273.       settings or matching baud rates by looking for start/stop
  2274.       bits.     Usually, all this is require is to sleep for a    second
  2275.       or two.  A more robust technique is to retry until the
  2276.       hardware is ready to receive input.  The following example
  2277.       uses both strategies:
  2278.  
  2279.           send "speed 9600\r";
  2280.           sleep 1
  2281.           expect {
  2282.           timeout {send    "\r"; exp_continue}
  2283.           $prompt
  2284.           }
  2285.  
  2286.  
  2287.  
  2288.      EEEEXXXXPPPPEEEECCCCTTTT HHHHIIIINNNNTTTTSSSS
  2289.       There    are a couple of    things about EEEExxxxppppeeeecccctttt that may be    non-
  2290.       intuitive.  This section attempts to address some of these
  2291.       things with a    couple of suggestions.
  2292.  
  2293.       A common expect problem is how to recognize shell prompts.
  2294.       Since    these are customized differently by differently    people
  2295.       and different    shells,    portably automating rlogin can be
  2296.       difficult without knowing the    prompt.     A reasonable
  2297.       convention is    to have    users store a regular expression
  2298.       describing their prompt (in particular, the end of it) in
  2299.       the environment variable EXPECT_PROMPT.  Code    like the
  2300.       following can    be used.  If EXPECT_PROMPT doesn't exist, the
  2301.       code still has a good    chance of functioning correctly.
  2302.  
  2303.           set prompt "(%|#|\\$) $"        ;# default prompt
  2304.  
  2305.  
  2306.  
  2307.      Page 35                        (printed 12/23/98)
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2315.  
  2316.  
  2317.  
  2318.           catch {set prompt    $env(EXPECT_PROMPT)}
  2319.  
  2320.           expect -re $prompt
  2321.  
  2322.       I encourage you to write eeeexxxxppppeeeecccctttt patterns that    include    the
  2323.       end of whatever you expect to    see.  This avoids the
  2324.       possibility of answering a question before seeing the    entire
  2325.       thing.  In addition, while you may well be able to answer
  2326.       questions before seeing them entirely, if you    answer early,
  2327.       your answer may appear echoed    back in    the middle of the
  2328.       question.  In    other words, the resulting dialogue will be
  2329.       correct but look scrambled.
  2330.  
  2331.       Most prompts include a space character at the    end.  For
  2332.       example, the prompt from ftp is 'f', 't', 'p', '>' and
  2333.       <blank>.  To match this prompt, you must account for each of
  2334.       these    characters.  It    is a common mistake not    to include the
  2335.       blank.  Put the blank    in explicitly.
  2336.  
  2337.       If you use a pattern of the form X*, the * will match    all
  2338.       the output received from the end of X    to the last thing
  2339.       received.  This sounds intuitive but can be somewhat
  2340.       confusing because the    phrase "last thing received" can vary
  2341.       depending upon the speed of the computer and the processing
  2342.       of I/O both by the kernel and    the device driver.
  2343.  
  2344.       In particular, humans    tend to    see program output arriving in
  2345.       huge chunks (atomically) when    in reality most    programs
  2346.       produce output one line at a time.  Assuming this is the
  2347.       case,    the * in the pattern of    the previous paragraph may
  2348.       only match the end of    the current line even though there
  2349.       seems    to be more, because at the time    of the match that was
  2350.       all the output that had been received.
  2351.  
  2352.       eeeexxxxppppeeeecccctttt has no    way of knowing that further output is coming
  2353.       unless your pattern specifically accounts for    it.
  2354.  
  2355.       Even depending on line-oriented buffering is unwise.    Not
  2356.       only do programs rarely make promises    about the type of
  2357.       buffering they do, but system    indigestion can    break output
  2358.       lines    up so that lines break at seemingly random places.
  2359.       Thus,    if you can express the last few    characters of a    prompt
  2360.       when writing patterns, it is wise to do so.
  2361.  
  2362.       If you are waiting for a pattern in the last output of a
  2363.       program and the program emits    something else instead,    you
  2364.       will not be able to detect that with the ttttiiiimmmmeeeeoooouuuutttt keyword.
  2365.       The reason is    that eeeexxxxppppeeeecccctttt will not timeout - instead it will
  2366.       get an eeeeooooffff indication.  Use that instead.  Even better, use
  2367.       both.     That way if that line is ever moved around, you won't
  2368.       have to edit the line    itself.
  2369.  
  2370.  
  2371.  
  2372.  
  2373.      Page 36                        (printed 12/23/98)
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2381.  
  2382.  
  2383.  
  2384.       Newlines are usually converted to carriage return, linefeed
  2385.       sequences when output    by the terminal    driver.     Thus, if you
  2386.       want a pattern that explicitly matches the two lines,    from,
  2387.       say, printf("foo\nbar"), you should use the pattern
  2388.       "foo\r\nbar".
  2389.  
  2390.       A similar translation    occurs when reading from the user, via
  2391.       eeeexxxxppppeeeecccctttt____uuuusssseeeerrrr.    In this    case, when you press return, it    will
  2392.       be translated    to a newline.  If EEEExxxxppppeeeecccctttt then passes that to a
  2393.       program which    sets its terminal to raw mode (like telnet),
  2394.       there    is going to be a problem, as the program expects a
  2395.       true return.    (Some programs are actually forgiving in that
  2396.       they will automatically translate newlines to    returns, but
  2397.       most don't.)    Unfortunately, there is    no way to find out
  2398.       that a program put its terminal into raw mode.
  2399.  
  2400.       Rather than manually replacing newlines with returns,    the
  2401.       solution is to use the command "stty raw", which will    stop
  2402.       the translation.  Note, however, that    this means that    you
  2403.       will no longer get the cooked    line-editing features.
  2404.  
  2405.       iiiinnnntttteeeerrrraaaacccctttt implicitly sets your    terminal to raw    mode so    this
  2406.       problem will not arise then.
  2407.  
  2408.       It is    often useful to    store passwords    (or other private
  2409.       information) in EEEExxxxppppeeeecccctttt scripts.  This    is not recommended
  2410.       since    anything that is stored    on a computer is susceptible
  2411.       to being accessed by anyone.    Thus, interactively prompting
  2412.       for passwords    from a script is a smarter idea    than embedding
  2413.       them literally.  Nonetheless,    sometimes such embedding is
  2414.       the only possibility.
  2415.  
  2416.       Unfortunately, the UNIX file system has no direct way    of
  2417.       creating scripts which are executable    but unreadable.
  2418.       Systems which    support    setgid shell scripts may indirectly
  2419.       simulate this    as follows:
  2420.  
  2421.       Create the EEEExxxxppppeeeecccctttt script (that contains the secret data) as
  2422.       usual.  Make its permissions be 750 (-rwxr-x---) and owned
  2423.       by a trusted group, i.e., a group which is allowed to    read
  2424.       it.  If necessary, create a new group    for this purpose.
  2425.       Next,    create a /bin/sh script    with permissions 2751
  2426.       (-rwxr-s--x) owned by    the same group as before.
  2427.  
  2428.       The result is    a script which may be executed (and read) by
  2429.       anyone.  When    invoked, it runs the EEEExxxxppppeeeecccctttt script.
  2430.  
  2431.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  2432.       TTTTccccllll(3), lllliiiibbbbeeeexxxxppppeeeecccctttt(3)
  2433.       "_E_x_p_l_o_r_i_n_g _E_x_p_e_c_t: _A _T_c_l-_B_a_s_e_d _T_o_o_l_k_i_t _f_o_r _A_u_t_o_m_a_t_i_n_g
  2434.       _I_n_t_e_r_a_c_t_i_v_e _P_r_o_g_r_a_m_s"    by Don Libes, pp. 602, ISBN 1-56592-
  2435.       090-2, O'Reilly and Associates, 1995.
  2436.  
  2437.  
  2438.  
  2439.      Page 37                        (printed 12/23/98)
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))         UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr    1111999999994444))))         EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2447.  
  2448.  
  2449.  
  2450.       "_e_x_p_e_c_t: _C_u_r_i_n_g _T_h_o_s_e    _U_n_c_o_n_t_r_o_l_l_a_b_l_e _F_i_t_s _o_f _I_n_t_e_r_a_c_t_i_v_i_t_y"
  2451.       by Don Libes,    Proceedings of the Summer 1990 USENIX
  2452.       Conference, Anaheim, California, June    11-15, 1990.
  2453.       "_U_s_i_n_g eeeexxxxppppeeeecccctttt    to Automate System Administration Tasks" by
  2454.       Don Libes, Proceedings of the    1990 USENIX Large Installation
  2455.       Systems Administration Conference, Colorado Springs,
  2456.       Colorado, October 17-19, 1990.
  2457.       "_T_c_l:    _A_n _E_m_b_e_d_d_a_b_l_e _C_o_m_m_a_n_d _L_a_n_g_u_a_g_e"    by John    Ousterhout,
  2458.       Proceedings of the Winter 1990 USENIX    Conference,
  2459.       Washington, D.C., January 22-26, 1990.
  2460.       "_e_x_p_e_c_t: _S_c_r_i_p_t_s _f_o_r _C_o_n_t_r_o_l_l_i_n_g _I_n_t_e_r_a_c_t_i_v_e _P_r_o_g_r_a_m_s" by
  2461.       Don Libes, Computing Systems,    Vol. 4,    No. 2, University of
  2462.       California Press Journals, November 1991.
  2463.       "_R_e_g_r_e_s_s_i_o_n _T_e_s_t_i_n_g _a_n_d _C_o_n_f_o_r_m_a_n_c_e _T_e_s_t_i_n_g _I_n_t_e_r_a_c_t_i_v_e
  2464.       _P_r_o_g_r_a_m_s", by    Don Libes, Proceedings of the Summer 1992
  2465.       USENIX Conference, pp. 135-144, San Antonio, TX, June    12-15,
  2466.       1992.
  2467.       "_K_i_b_i_t_z - _C_o_n_n_e_c_t_i_n_g _M_u_l_t_i_p_l_e    _I_n_t_e_r_a_c_t_i_v_e _P_r_o_g_r_a_m_s
  2468.       _T_o_g_e_t_h_e_r", by    Don Libes, Software - Practice & Experience,
  2469.       John Wiley & Sons, West Sussex, England, Vol.    23, No.    5,
  2470.       May, 1993.
  2471.       "_A _D_e_b_u_g_g_e_r _f_o_r _T_c_l _A_p_p_l_i_c_a_t_i_o_n_s", by    Don Libes, Proceedings
  2472.       of the 1993 Tcl/Tk Workshop, Berkeley, CA, June 10-11, 1993.
  2473.  
  2474.      AAAAUUUUTTTTHHHHOOOORRRR
  2475.       Don Libes, National Institute    of Standards and Technology
  2476.  
  2477.      AAAACCCCKKKKNNNNOOOOWWWWLLLLEEEEDDDDGGGGMMMMEEEENNNNTTTTSSSS
  2478.       Thanks to John Ousterhout for    Tcl, and Scott Paisley for
  2479.       inspiration.    Thanks to Rob Savoye for Expect's
  2480.       autoconfiguration code.
  2481.  
  2482.       The HISTORY file documents much of the evolution of eeeexxxxppppeeeecccctttt.
  2483.       It makes interesting reading and might give you further
  2484.       insight to this software.  Thanks to the people mentioned in
  2485.       it who sent me bug fixes and gave other assistance.
  2486.  
  2487.       Design and implementation of EEEExxxxppppeeeecccctttt was paid for in part by
  2488.       the U.S. government and is therefore in the public domain.
  2489.       However the author and NIST would like credit    if this
  2490.       program and documentation or portions    of them    are used.
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.      Page 38                        (printed 12/23/98)
  2506.  
  2507.  
  2508.  
  2509.